Java 打包
1、maven update 项目
选择Java项目,右键--maven -- update Maven Dependencies--OK
2、打包前工程配置
Following are the steps which I followed to resolve this issue:
- Create a resources folder in your src/main(ie src/main/resources)
- Create a META-INF folder in your src/main/resources
- Make MANIFEST.MF, spring.handlers and spring.schemas files under src/main/resources/META-INF.
- Paste the following in plugins section of your pom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version> 1.4 </version> <executions> <execution> <phase> package </phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation= "org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" > <mainClass> com.company.project.Main </mainClass> </transformer> <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> <shadedArtifactAttached> true </shadedArtifactAttached> <!-- optional --> <shadedClassifierName>executable</shadedClassifierName> </configuration> </execution> </executions> </plugin> |
(参考)http://www.cnblogs.com/lhj588/archive/2012/03/23/2414318.html
3、打包
cmd
cd Java项目跟目录下。
maven clean
maven package
4、java -jar 打包好的Jar包, (运行程序)