【问题标题】:Build Spring Roo / Export maven project with Eclipse Export -> Runnable JAR file使用 Eclipse Export -> Runnable JAR 文件构建 Spring Roo / Export maven 项目
【发布时间】:2011-02-19 06:54:03
【问题描述】:

我在 STS 2.5.1.RELEASE 中使用 Spring roo 创建了 Maven 项目(它是 Eclipse 3.6.1 + Spring tools + m2eclipse)。我在构建路径上有第二个简单的 Java 项目。在 Eclipse 中一切正常。

现在的问题是构建。我不能用 maven 这样做,因为它还要求引用的项目是 maven 项目。对于引用的项目,我只使用 Eclipse Export -> Runnable JAR file 来导出并生成 ant 文件以供下一次构建。

为第一个项目这样做,我得到运行时错误,即使 META-INF/spring/applicationContext.xml 既是 .jar 又在 .jar 旁边的文件夹中

2011-02-19 13:58:39,135-org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/spring/applicationContext.xml]
2011-02-19 13:58:39,405-org.springframework.core.io.support.PathMatchingResourcePatternResolver - Cannot search for matching files underneath URL [rsrc:com/company/test/] because it does not correspond to a directory in the file system
java.io.FileNotFoundException: URL [rsrc:com/company/test/] cannot be resolved to absolute file path because it does not reside in the file system: rsrc:com/company/test/
    at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:204)

引用的项目正在大力开发中,我无法移动、重构它或改变它的性质。 Spring roo 的 Maven 项目是并行版本待开发。

如何使用包含的eclipse项目构建maven项目?

示例。 项目 /RooInheritanceMaven 在其 (eclipse) 构建路径上有项目 /RooInheritanceJava。

.classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="target/classes" path="src/main/java"/>
    <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
    <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
    <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
    <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
    <classpathentry combineaccessrules="false" kind="src" path="/RooInheritanceJava"/>
    <classpathentry kind="output" path="target/classes"/>
</classpath>

【问题讨论】:

    标签: eclipse spring maven m2eclipse spring-roo


    【解决方案1】:

    Eclipse Export to Executable JAR 与 Spring 不兼容。 更准确地说是

    org.springframework.core.io.support.PathMatchingResourcePatternResolver
    

    以前有类似的问题。见

    #SPR-3815 Classloader problem - Spring Projects Issue Tracker

    试试

    jar -tf PersonApp.jar >PersonApp.jar.txt
    

    解决方案是将 .classes 和所有东西从 jar 提取到文件夹中

    jar xf PersonApp.jar
    

    并运行为

    set CLASSPATH=D:\TEMP\KDF.MSSQL\antlr-2.7.6.jar;D:\TEMP\KDF.MSSQL\aopalliance-1.0.jar; <... all jar dependecies listed>
    java com/company/PersonApp
    

    【讨论】:

    • “解决方案是将 .classes 和所有东西从 jar 提取到文件夹中”,这个语句对我有用
    【解决方案2】:
    【解决方案3】:

    使用 Roo 命令

    perform package
    

    将您的应用程序捆绑在一起 - 以便您可以将其部署到您自己的容器中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-19
      相关资源
      最近更新 更多