Ant + 类路径问题 [英] Ant + Class-path Issue

查看:35
本文介绍了Ant + 类路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个 ANT 脚本,最后正在构建 jar

I have written an ANT script and finally am building the jar

这里是jar部分的构建

here is the building of jar section

<jar jarfile="${destination}/@{name}.jar">
     <fileset dir="${output}">
         <include name="abc/xyz/@{name}/**"/>
     </fileset>
     <zipfileset dir="lib" prefix="lib/"/>
     <manifest>
          <attribute name="Main-Class" value="com.abc.xyz.HelloWorld"/>
          <attribute name="Class-Path" value=".:lib/activation.jar:lib/antlr-2.7.6.jar:lib/asm-attrs.jar:lib/asm.jar:lib/cglib-2.1.3.jar:lib/commons-collections-2.1.1.jar:lib/commons-logging-1.1.jar:lib/dom4j-1.6.1.jar:lib/ehcache-1.2.3.jar:lib/ejb3-persistence.jar:lib/hibernate-annotations.jar:lib/hibernate-commons-annotations.jar:lib/hibernate-entitymanager.jar:lib/hibernate-tools.jar:lib/hibernate3.jar:lib/javassist.jar:lib/jdbc2_0-stdext.jar:lib/jta.jar:lib/mysql-connector-java-5.1.5-bin.jar"/>
     </manifest>
</jar>

现在,当我尝试执行它执行的包时,但每当发送数据时,我都会收到错误消息.

Now when I try to execute the package it executes, but whenever data is sent I get an error.

java.lang.NoClassDefFoundError: javax/persistence/NoResultException

但是持久化 jar 在类路径中,我已经尝试了类路径的所有组合,但没有成功.

But the persistence jar is there in the class-path, I've tried all the combinations for the class-path, but in vain.

但在另一个系统中,我尝试不创建类似的 jar

But in another system I tried without create a jar like

set classpath=.;lib/activation.jar;lib/antlr-2.7.6.jar;lib/asm-attrs.jar;lib/asm.jar;lib/cglib-2.1.3.jar;lib/commons-collections-2.1.1.jar;lib/commons-logging-1.1.jar;lib/dom4j-1.6.1.jar;lib/ehcache-1.2.3.jar;lib/ejb3-persistence.jar;lib/hibernate-annotations.jar;lib/hibernate-commons-annotations.jar;lib/hibernate-entitymanager.jar;lib/hibernate-tools.jar;lib/hibernate3.jar;lib/javassist.jar;lib/jdbc2_0-stdext.jar;lib/jta.jar;lib/mysql-connector-java-5.1.5-bin.jar
java com.abc.xyz.HelloWorld

这很好用.

在 Mac 中,当我这样尝试时:

In Mac when I try like this:

java -cp .:lib/activation.jar:lib/antlr-2.7.6.jar:lib/asm-attrs.jar:lib/asm.jar:lib/cglib-2.1.3.jar:lib/commons-collections-2.1.1.jar:lib/commons-logging-1.1.jar:lib/dom4j-1.6.1.jar:lib/ehcache-1.2.3.jar:lib/ejb3-persistence.jar:lib/hibernate-annotations.jar:lib/hibernate-commons-annotations.jar:lib/hibernate-entitymanager.jar:lib/hibernate-tools.jar:lib/hibernate3.jar:lib/javassist.jar:lib/jdbc2_0-stdext.jar:lib/jta.jar:lib/mysql-connector-java-5.1.5-bin.jar com.abc.xyz.HelloWorld

它也可以正常工作:(,但是我创建 jar 的那一刻它就停止了.

Also it works fine :(, but the minute I create the jar it stops.

我该如何解决这个问题?

How can I resolve this issue?

推荐答案

不工作的原因是类路径中没有,解释如下:Java-Jar-Ignores-Classpath-Workaround

The reason for it not works was there not in the class path, the explanation is given here: Java-Jar-Ignores-Classpath-Workaround

这篇关于Ant + 类路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆