与Ant文件帮助

编程入门 行业动态 更新时间:2024-10-27 10:26:36
本文介绍了与Ant文件帮助 - 类路径中的Java任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有蚂蚁以下构建文件,并尝试使用执行该程序运行目标。

I have the below build file for Ant and trying to use the target 'run' for executing the program.

<property name="springjar" location="E:/Tools/spring-30/dist/" /> <property name="logjar" location="E:/Tools/commons-logging-1.1.1/" /> <patternset id="jar.files"><include name="**/*.jar"/></patternset> <path id="springlearn.classpath"> <fileset dir="${springjar}"><patternset refid="jar.files"/></fileset> <fileset dir="${logjar}"><patternset refid="jar.files"/></fileset> </path> <target name="run" depends="dist" description="Execute the Java Program"> <java dir ="." fork="true" jar="dist\app.jar" classpathref ="springlearn.classpath"> </java> </target>

使用相同的classpathref,我能够成功地编译和放大器;创建JAR,但使用目标运行时,我得到下面的错误

Using the same classpathref, I am able to successfully compile & create the jar, but when use the target run, I get the below error

java.lang.NoClassDefFoundError: org/springframework/core/io/Resource Caused by: java.lang.ClassNotFoundException: org.springframework.core.io.Resource at java.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:289) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

异常线程main

Exception in thread "main"

任何帮助是极大AP preciated。谢谢

Any help is greatly appreciated. Thanks

推荐答案

从 的java 任务文档:

在使用jar属性,所有的类路径设置根据的 Sun的规范。

When using the jar attribute, all classpath settings are ignored according to Sun's specification.

所以,你设置的路径并不被看的。

So the classpath you set up isn't being looked at at all.

您可以添加 DIST / app.jar 到类路径中并调用主类直接:

You could add dist/app.jar to your classpath and call the main class direct:

<java dir ="." fork="true" classname="com.yourdomain.YourMainClass"> <classpath> <path refid="springlearn.classpath" /> <pathelement location="dist\app.jar" /> </classpath> </java>

如果您要拨打的罐子,你需要建立一个类路径条目在清单中,当你构建它。看一看在 pathconvert 的任务,它可能是有益的。

If you want to call the jar, you'll need to set up a classpath entry in the manifest when you build it. Have a look at the pathconvert task, it could be useful.

更多推荐

与Ant文件帮助

本文发布于:2023-10-05 09:39:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1467352.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   Ant

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!