IDEA连同依赖一起打包
程序员文章站
2022-06-17 14:49:40
...
1.跑一个简单的程序,但是服务器上有些依赖没有,需要将依赖都打入jar包,这时候,要是使用eclipse,普通的Java程序的话,需要安装一个插件,fatjar,通过这个插件将依赖都打入jar。
2.如果是maven工程的话,就好说了,直接在pom文件加入依赖就可以了。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>CSVUtil</mainClass>
</configuration>
</plugin>
<!-- maven jar in main class and dependencies start -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>CSVUtil</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- maven jar in main class and dependencies end -->
</plugins>
</build>