本地用例跑通之后,就涉及到了如何進行打包部署的問題。
若采用的是maven工具來管理項目,會涉及到如下問題
首先是pom.xml文件配置,
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
如果只是進行單元測試,只需添加如上代碼即可。
如果進行集成測試,還需要添加
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> </configuration> </plugin> </plugins> </build>
之后開始打包,使用命令
mvn clean package -Dmaven.test.skip=true
打包好后使用后臺運行的方式啟動
nohup java -jar target/spring-boot-scheduler-1.0.0.jar &
PS:
1、假如想看jar包里都包括什么,可以去maven中的jar包打開META-INF里的pom文件,就能看到了。
2、有用的鏈接:
spring boot +testng,第一個鏈接尤其有用
這個講一些原理,也挺有用的
浙公網安備 33010602011771號