User Tools

Site Tools


tech:maven-related

dependency下的scope详解

compile:  默认的scope,表示 dependency 都可以在生命周期中使用。
而且这些dependencies 会传递到依赖的项目中。适用于所有阶段,会随着项目一起发布

provided: 跟compile相似,但是表明了dependency 由JDK或者容器提供,例如Servlet AP和一些Java EE APIs。
这个scope 只能作用在编译和测试时,同时没有传递性。

runtime: 表示dependency不作用在编译时,但会作用在运行和测试时,如JDBC驱动,适用运行和测试阶段。

test: 表示dependency作用在测试时,不作用在运行时。 只在测试时使用,用于编译和运行测试代码。不会随项目发布。

system: 跟provided 相似,但是在系统中要以外部JAR包的形式提供,maven不会在repository查找它。

查看某个jar被哪些依赖引入

比如
<groupId>redis.clients</groupId>
<artifactId>jedis</articfactId>

mvn dependency:tree -Dverbose -Dincludes=redis.clients:jedis

mvn dependency:tree -Dverbose -Dincludes=com.fasterxml.jackson.dataformat:jackson-dataformat-cbor

用来查到某一个包到底是被谁引入的

mvn dependency:tree -Dverbose -Dincludes=org.elasticsearch:elasticsearch -s C:\private\tool\settings-101.xml

mvn archetype:create -DgroupId=com.starcite.scm -DartifactId=scm-web -DarchetypeArtifactId=maven-archetype-webapp
mvn archetype:create -DarchetypeGroupId=scm -DgroupId=com.starcite.scm -DartifactId=my-app
mvn archetype:generate -DarchetypeGroupId=scm -DgroupId=com.starcite.scm -DartifactId=my-app
java -cp target/my-app-1.0-SNAPSHOT.jar com.starcite.scm.App
mvn -Dmaven.scm.svn.config_directory=scm:svn:https://morgan.liao:Q?Z_zGkrma=@scm.starcite.com/svn/scm-tools/scm/ scm:update
mvn package -Dmaven.test.failure.ignore=true
tech/maven-related.txt · Last modified: 2023/01/11 11:59 by morgan0329

Except where otherwise noted, content on this wiki is licensed under the following license: 沪ICP备12046235号-2
Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki