maven的war plugin插件裏有兩個參數warSourceExcludes和packagingExcludes,從clean package後的效果來講,他們都能起到打war包時不包含指定文件夾或者指定文件的做用。web
可是他們實現的方式不同。按照plugin中對這兩個參數的說明:app
warSourceExcludes: The comma separated list of tokens to exclude when copying the content of the warSourceDirectory.webapp
packagingExcludes: The comma separated list of tokens to exclude from the WAR before packaging.maven
With packagingExcludes, the tokens are completely excluded from the final war file. With warSourceExcludes, the tokens are just ignored when copying the war directory into the war file. As a result, if the tokens are present in the webappDirectory for example, they will not be ignored when using warSourceExcludes but will be when usingpackagingExcludes.插件
warSourceExcludes是在拷貝文件到war文件夾時忽略掉指定文件或者文件夾(可是若是war命令前沒有clean指令,而war文件夾下已經包含了指定文件或者文件夾時,最後生成的war包裏仍是會包含這些文件或文件夾,哪怕沒有拷貝它們到war文件夾).token
packagingExcludes是在生成war包時不包含指定文件或文件夾到war文件中,不論它們是否存在於war文件夾下。it
所以慎重起見,更傾向於使用packagingExcludes參數。file