关于 mvn dependency:analyze Unused declared dependencies found 问题
Posted
技术标签:
【中文标题】关于 mvn dependency:analyze Unused declared dependencies found 问题【英文标题】:About mvn dependency:analyze Unused declared dependencies found problem 【发布时间】:2019-09-24 16:15:14 【问题描述】:我运行mvn dependency:analyze
命令检查我的java项目中未使用的jar,部分结果如下:
[WARNING] 发现未使用的已声明依赖项:[WARNING] org.springframework.boot:spring-boot-starter:jar:2.0.3.RELEASE:comp [警告] org.springframework.boot:spring-boot-starter-test:jar:2.0.3.RELEASE :compile [警告] org.springframework.boot:spring-boot-starter-jdbc:jar:2.0.3.RELEASE :compile [警告] org.springframework.boot:spring-boot-starter-actuator:jar:2.0.3.REL 轻松:编译 [警告] org.aspectj:aspectjweaver:jar:1.8.9:compile [警告]
但是spring-boot-starter-test
其实是用在src/test/java包里的,
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)
public class TestClass
...
我想知道为什么 spring-boot-starter-test: 会出现在 Unused declared dependencies found 部分。 有没有办法找到我的java项目中没有使用的确切jar
【问题讨论】:
【参考方案1】:如果您声明的依赖项没有<scope>
标签,则将使用<scope>compile</scope>
。
如果仅用于测试,则应将其声明为<scope>test</scope>
。
【讨论】:
嗨 dan1st:我试过以上是关于关于 mvn dependency:analyze Unused declared dependencies found 问题的主要内容,如果未能解决你的问题,请参考以下文章