现在写后端非WEB程序比较多,每次需要手工的拷贝lib里面的jar 包,然后启动脚本里面还要写classpath,特么完全是在坑爹,为了偷懒,我找了一下maven中的配置,发现可以配置可运行包,并且直接拷贝依赖JAR到lib下,还把classpath放在打包好的程序描述文件中,简直是神器,这里留下一笔,免得以后一段时间不写代码了把这个给忘记了,呵呵.
mvn clean install
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>com.coffee.bee.Main</mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> </build>