User Tools

Site Tools


tech:maven-related

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
tech:maven-related [2022/10/29 00:39] morgan0329tech:maven-related [2023/01/11 11:59] (current) morgan0329
Line 1: Line 1:
 +====== dependency下的scope详解 ======
 +<code>
 +compile:  默认的scope,表示 dependency 都可以在生命周期中使用。
 +而且这些dependencies 会传递到依赖的项目中。适用于所有阶段,会随着项目一起发布
  
 +provided: 跟compile相似,但是表明了dependency 由JDK或者容器提供,例如Servlet AP和一些Java EE APIs。
 +这个scope 只能作用在编译和测试时,同时没有传递性。
 +
 +runtime: 表示dependency不作用在编译时,但会作用在运行和测试时,如JDBC驱动,适用运行和测试阶段。
 +
 +test: 表示dependency作用在测试时,不作用在运行时。 只在测试时使用,用于编译和运行测试代码。不会随项目发布。
 +
 +system: 跟provided 相似,但是在系统中要以外部JAR包的形式提供,maven不会在repository查找它。
 +</code>
 +
 +
 +====== 查看某个jar被哪些依赖引入 ======
 +<code>
 +比如
 +<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
 +</code>
 +
 +====== 用来查到某一个包到底是被谁引入的 ======
 +
 +mvn dependency:tree -Dverbose -Dincludes=org.elasticsearch:elasticsearch -s C:\private\tool\settings-101.xml
 +
 +
 +<code>
 +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
 +</code>
 +
 +
 +<code>
 +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
 +
 +</code>

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