gradle providedCompile 与compile区别

版权声明:嘿嘿嘿 https://blog.csdn.net/luzhensmart/article/details/85488679
/**
 * maven:provided
 * provided:在编译和测试的过程有效,最后生成war包时不会加入,诸如:servlet-api,
 * 因为servlet-api,tomcat等web服务器已经存在了,如果再打包会冲突
 * gradle:provided和compile的区别:
 * 如果你的jar包/依赖代码 仅在编译的时候需要,但是在运行时不需要依赖,就用providedCompile
 * 此属性 相当于maven中的provided
 */

Gradle compile:
 如果你的jar包/依赖代码 在编译的时候需要依赖,在运行的时候也需要,那么就用compile
 例如 :

compile group: 'org.springframework', name: 'spring-context', version: '5.0.2.RELEASE';

Gradle providedCompile:
如果你的jar包/依赖代码 仅在编译的时候需要,但是在运行时不需要依赖,就用providedCompile
例如:

compileOnly group: 'javax.servlet', name: 'servlet-api', version:'3.1.0'
compileOnly group: 'javax.servlet', name: 'jsp-api', version: '2.0'

猜你喜欢

转载自blog.csdn.net/luzhensmart/article/details/85488679
今日推荐