Maven:使用一个 Jar 中的所有依赖项进行编译
在项目的 pom 中,我添加了对scopecompile的依赖。这是一个 jar 文件,其中还包含一些类文件和 jar 文件。我当前的java文件需要依赖jar的内部jar来编译。
但是maven编译目标返回编译错误。 :banghead:
编译所需的所有 jar 都在依赖项中添加的单个 jar 文件中......................................
请帮我!
我的pom:
<project>
<!-- ... -->
<dependencies>
<dependency>
<groupId>eagle</groupId>
<artifactId>zkui</artifactId>
<version>360LTS</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>./src/main/java</sourceDirectory>
<outputDirectory>./target/classes</outputDirectory>
<finalName>${project.groupId}-${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
错误:
包 org.zkoss.zk.ui 不存在 这个包 org.zkoss.zk.ui 在 jar 中 依赖文件 zkex.jar jar eagle:zkui:360LTS jar 文件
请帮助我!!!! :jumpingjoy:
提前谢谢
in pom of a project, i have added dependency with scope compile . which is a jar file which contains some class file and jar's as well. my current java file needs internal jars of dependent jar to compile.
But maven compile goal returning compilation error . :banghead:
All the jar's needed to compile are in the single jar file which is added in dependency.............................
Please help me!
my pom:
<project>
<!-- ... -->
<dependencies>
<dependency>
<groupId>eagle</groupId>
<artifactId>zkui</artifactId>
<version>360LTS</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>./src/main/java</sourceDirectory>
<outputDirectory>./target/classes</outputDirectory>
<finalName>${project.groupId}-${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
error:
package org.zkoss.zk.ui does not exist
this package org.zkoss.zk.ui is in jar
file zkex.jar which is in dependency
jar eagle:zkui:360LTS jar file
Please Help ME!!!! :jumpingjoy:
Advance Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,我想你可以
dependency:unpack
将 jar 解压到 target/lib 左右(编译前)停用
compiler:compile
通过排除所有内容<前><代码><排除>
<排除>**/*.java
使用
antrun:run
与 antjavac
任务来编译源代码,如下所示(将执行绑定到阶段compile
):<预置><代码><目标>
;
>
<类路径>
但是,虽然这会帮助您编译应用程序,但它不会帮助您运行或部署您的应用程序。
Well I guess you could
dependency:unpack
to unpack the jars to target/lib or so (before compile)deactivate
compiler:compile
by excluding everythinguse
antrun:run
with the antjavac
task to compile the sources, something like this (bind the execution to phasecompile
):However, while that would help you compile your application, it would not help you run or deploy your application.
您可以使用该元素来执行此操作:
您需要引用(并在类路径中)的 jar 是 lib/jarname.jar,并且 lib 目录位于项目的根目录中。
You can use the element to do this:
where the jar you need to reference (and have in your classpath) is lib/jarname.jar, and the lib directory is in the root of your project.
我相信您实际上没有使用正确的依赖项。 ZK 实际上有 Maven 存储库,如此处所述。
您需要检查您需要哪些依赖项。例如,对于 zkex,您需要类似以下内容:
您还需要添加 ZK Maven 存储库:
祝您好运! :-)
I believe you're actually not using the proper dependencies. ZK actually have Maven repositories as described here.
You need to check which dependencies you need. For example for zkex, you would need something like:
You will also need to add the ZK Maven repositories:
Good luck! :-)