1. 程式人生 > >Maven專案編譯打包命令

Maven專案編譯打包命令

在Eclipse中的pom.xml上可以執行Maven有關命令
Maven命令

1、編譯 compile

1.1右鍵Run As,選擇2 Maven build,在目標Goals中錄入compile

compile

1.2點選Run,在控制檯檢視執行情況

執行情況

1.3 target目錄下,檢視編譯生成的class檔案

2、打包 package

支援動態打包,web工程生成war包,Java工程生成jar包,我的專案是java
package
控制檯中檢視執行結果:BUILD SUCCESS,說明執行成功,前往target目錄檢視jar包
jar包

3、單元測試 test

3.1測試類,測試mybatis

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring-mybatis.xml"})
public class TestMyBatis {
	@Resource
	private ICxbb cxbbService = null;
	@Resource
	CxbbKey keyCxbb;	
	@Test
	public void test1() {
		String mc = "Spring.SpingMVC.mybatis.zip";
		HlwDmCxbb cxbb =
cxbbService.selectByPKStr(mc); //輸出結果 System.out.println("test1 - MD5: "); System.out.println(cxbb.getMd5()); //也可以使用JUnit斷言Assert } }

3.2執行測試

3.2.1在目標Goals中錄入test,或在類TestMyBatis上右鍵執行JUint Test
test
3.2.2控制檯檢視結果
結果
3.2.3target目錄中的surefire-reports檢視結果報告
共生成兩個檔案,一個是結果,一個是執行環境
reports