简体   繁体   中英

.jar with Maven and Eclipse

I have a java project done with Eclipse and Maven with this estructure folder: enter image description here

Ok, when i make a Maven install to create the .jar take this structure folder:

enter image description here

So that the hierarchy is not the same and links to the images and css do not work.

I show you the code of pom.xml

enter code here

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.wepall palle 0.4.0 com.thoughtworks.xstream xstream com.thoughtworks.xstream xstream 1.4.9 palle

        <!-- 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>

Any ideas?

thanks a lot!! Best regards

I think that you should create a war instead of a jar , because you are talking about css and images and jars should not contains that kind of files (see jar vs war ).

In maven you only need to change the <packaging> of the project inside the POM.

You should add a build section to your

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

Further Reference: POM Reference (Build Section)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM