我运行mvn dependency:analyze
命令来检查Java项目中未使用的jar,结果部分如下:
[警告] 发现未使用的声明依赖项:[警告]
org.springframework.boot:spring-boot-starter:jar:2.0.3.RELEASE:comp ile [警告]
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 EASE:compile [警告] 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:出现在未使用的已声明依赖项部分中。
有没有一种方法可以找到我的Java项目中未使用的确切的jar
答案 0 :(得分:0)
如果您声明的依赖项没有<scope>
标记,将使用<scope>compile</scope>
。
如果仅将其用于测试,则应将其声明为<scope>test</scope>
。