2016-05-24 71 views
0

我与Eclipse和Maven做这个estructure文件夹中的Java项目: enter image description here的.jar与Maven和Eclipse

好吧,当我做一个Maven安装创建的.jar采取这种结构的文件夹:

enter image description here

因此,层次结构是不一样的,并链接到图像和CSS不起作用。

我告诉你的pom.xml的

enter code here 

http://maven.apache.org/xsd/maven-4.0.0.xsd“代码> 4.0.0 com.wepall 帕勒 0.4.0 com.thoughtworks.xstream XStream的 com.thoughtworks.xstream XStream的 1.4.9 帕勒

 <!-- download source code in Eclipse, best practice --> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-eclipse-plugin</artifactId> 
      <version>2.9</version> 
      <configuration> 
       <downloadSources>true</downloadSources> 
       <downloadJavadocs>false</downloadJavadocs> 
      </configuration> 
     </plugin> 

     <!-- Set a compiler level --> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>${jdk.version}</source> 
       <target>${jdk.version}</target> 
      </configuration> 
     </plugin> 

     <!-- Maven Assembly Plugin --> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.6</version> 
      <configuration> 
       <!-- get all project dependencies --> 
       <descriptorRefs> 
        <descriptorRef>jar-with-dependencies</descriptorRef> 
       </descriptorRefs> 
       <!-- MainClass in mainfest make a executable jar --> 
       <archive> 
        <manifest> 
         <mainClass>com.wepall.palle.MainApp</mainClass> 
        </manifest> 
       </archive> 

      </configuration> 
      <executions> 
       <execution> 
        <id>make-assembly</id> 
        <!-- bind to the packaging phase --> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

    </plugins> 
</build> 

任何想法?

非常感谢! 最好的问候

+0

你能成为一个更具体一点??? –

+0

是的,对不起,mi问题是关于.jar的herarky文件夹, 我解释你, – wepall

+0

当我让.jar没有生成具有该项目的层次结构时,src的原始结构是src \ main \ java \ com \ wepall \ palle和src \ main \ resources ,最后是在java文件夹内,资源文件夹位于同一个文件夹中。 什么时候它必须是一个java的文件夹和一个com文件夹(包含类)和其他资源以及文件夹css,Images,lib,Projects,RobotFiles内部。 – wepall

回答

0

您应该添加一个生成部分,将的pom.xml:

<build> 
     <directory>${basedir}/target</directory> 
     <resources> 
      <resource> 
       <targetPath>${basedir}/target/resources</targetPath> 
       <directory>${basedir}/src/main/resources</directory> 
      </resource> 
     </resources> 
</build> 

进一步参考: POM Reference (Build Section)

+0

非常感谢您的回复,现在这个代码的目标是很好的构建,但不是.jar,资源不在.jar – wepall

+0

解决!使用相同的代码,但是: $ {basedir}/target/classes/resources现在jar具有与项目相同的文件夹层次结构。非常感谢你的帮助!!!! – wepall

0

我认为你应该创建一个war代替jar,因为你是在谈论CSS和图像罐子不应该包含类型的文件(见jar vs war)的。

在maven中,您只需要更改POM中项目的<packaging>