简体   繁体   中英

Export as an executable jar file

I have an maven eclipse project which I want to export as an executable jar file from command line. I have external library jars also in the project. How can I get the executable jar file inclusive of all library jars from command line?

EDIT:: Now there is a challenge.There are actually two projects.One is PROJECT and other is Project_Framework . Both these folders are having pom.xml .The dependencies are written in pom.xml in PROJECT folder. PROJECT is dependen t on Project_Framework . After adding maven-shade plugin it is saying it cannot find the snapshot dependency of Project_Framework . How can I solve this?

You have to use the maven-shade-plugin to add all dependecies to your jar.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <finalName>${project.build.finalName}</finalName>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                        <resource>META-INF/spring.handlers</resource>
                    </transformer>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                        <resource>META-INF/spring.schemas</resource>
                    </transformer>
                </transformers>
            </configuration>
        </plugin>

Then Change directory to PROJECT_FRAMEWORK .Then type

mvn install

Then, again change directory to PROJECT . If you have added it, you can simply run

mvn package .

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