Jar 使用Maven3将文件夹添加到类路径的正确方法
所以我使用的是WAS8.5,我需要在我的项目中包含WAS库。我试过这个Jar 使用Maven3将文件夹添加到类路径的正确方法,jar,websphere,maven-3,websphere-8,Jar,Websphere,Maven 3,Websphere 8,所以我使用的是WAS8.5,我需要在我的项目中包含WAS库。我试过这个 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Class-Path>C:\Program Files (x86)\IBM\WebSphere\AppServer\plugins</Class-Path>
<Class-Path>C:\Program Files (x86)\IBM\WebSphere\AppServer\java\jre\lib</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
org.apache.maven.plugins
maven jar插件
真的
真的
C:\ProgramFiles(x86)\IBM\WebSphere\AppServer\plugins
C:\ProgramFiles(x86)\IBM\WebSphere\AppServer\java\jre\lib
但我仍然明白
错误:包javax.jms不存在
尽管
二进制文件./plugins/javax.j2ee.jms.jar匹配
但这似乎对mvn包不起作用,所以我的问题有两个方面
1.)我应该使用mvn包还是mvn jar:jar,因为后者似乎无法识别我的类的存储位置。如果我应该使用jar,我如何包括源目录
2.)如果我使用的是包,那么如何将文件夹包含在类路径中?我想你说的是编译时问题,而不是运行时问题。清单信息用于运行时,您正确配置它的方式使其仅对您的系统有用。 ApacheMaven是关于可预测的构建的,这意味着您必须定义每个依赖项,而不是定义一个库文件夹。 您应该将所需的JAR“安装”到本地存储库中(安装实际上是复制到)。
请参见我找到的自动化构建且不必使用命令行的最佳解决方案是使用maven安装插件从我的pom.xml进行安装:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>proguard</id>
<inherited>false</inherited>
<phase>validate</phase>
<configuration>
<file>${pom.basedir}/lib/proguard-4.8.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard</artifactId>
<version>4.8</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</plugin>
org.apache.maven.plugins
maven安装插件
2.2
前卫
假的
验证
${pom.basedir}/lib/proguard-4.8.jar
违约
net.sf.proguard
前卫
4.8
罐子
真的
安装文件
因此,我将jar放入$PROJECT_HOME/lib文件夹,并将此执行添加到验证阶段,以便在每个maven执行中安装它
这是大量的文本,但它完全自动化了在其他机器上的构建。所以这就是我最终要做的,但这很乏味。这真的是唯一的解决方案吗?这是最好的解决方案。所有其他的把戏都是恶作剧,总有一天会咬到你的。我假设(或希望)你不是每天、每周或每月都在换新版本。这是这些罐子的一次性安装。你可以把你的情况与你的情况相比较