识别 Maven 中的依赖项
Posted
技术标签:
【中文标题】识别 Maven 中的依赖项【英文标题】:Identifying Dependencies in Maven 【发布时间】:2021-03-27 04:39:20 【问题描述】:我们有一个使用 maven 构建的 Spring Boot 项目。现在我必须确定哪些依赖项很重要,哪些不应该构建到 jar 文件中,哪些不应该。我找到了一个命令“mvn dependency:analyze”,它显示了未使用和已使用的依赖项。
例如,在未使用的依赖项下,我可以看到 lombok 被列出,未使用的依赖项应该被删除我阅读,但如果我删除它,我无法执行 mvn clean install,因为我们的项目中使用了 lombok。
我的问题是如何以安全的方式清理 pom?并从 jar 中排除依赖项。我是 Maven 新手。
这是使用未声明的依赖项:
[WARNING] Used undeclared dependencies found:
[WARNING] org.springframework.data:spring-data-commons:jar:2.1.12.RELEASE:compile
[WARNING] org.springframework.boot:spring-boot-test:jar:2.1.10.RELEASE:test
[WARNING] org.springframework:spring-beans:jar:5.1.11.RELEASE:compile
[WARNING] org.hibernate:hibernate-core:jar:5.3.13.Final:compile
[WARNING] org.elasticsearch:elasticsearch:jar:6.4.3:compile
[WARNING] org.hamcrest:hamcrest-library:jar:1.3:test
[WARNING] org.slf4j:slf4j-api:jar:1.7.29:compile
[WARNING] org.springframework.security:spring-security-config:jar:5.1.7.RELEASE:compile
[WARNING] org.zalando:problem-spring-common:jar:0.25.2:compile
[WARNING] org.keycloak:keycloak-adapter-core:jar:4.6.0.Final:compile
[WARNING] org.springframework.boot:spring-boot:jar:2.1.10.RELEASE:compile
[WARNING] com.github.vanroy:spring-data-jest:jar:3.2.5.RELEASE:compile
[WARNING] org.springframework.security:spring-security-core:jar:5.1.7.RELEASE:compile
[WARNING] com.fasterxml.jackson.core:jackson-annotations:jar:2.9.10:compile
[WARNING] net.logstash.logback:logstash-logback-encoder:jar:6.3:compile
[WARNING] javax.annotation:javax.annotation-api:jar:1.3.2:compile
[WARNING] org.springframework:spring-test:jar:5.1.11.RELEASE:test
[WARNING] org.keycloak:keycloak-spring-boot-adapter-core:jar:4.6.0.Final:compile
[WARNING] com.fasterxml.jackson.core:jackson-databind:jar:2.9.10.1:compile
[WARNING] org.hamcrest:hamcrest-core:jar:1.3:test
[WARNING] org.zalando:problem-violations:jar:0.25.2:compile
[WARNING] org.springframework:spring-tx:jar:5.1.11.RELEASE:compile
[WARNING] org.springframework.data:spring-data-jpa:jar:2.1.12.RELEASE:compile
[WARNING] org.springframework:spring-web:jar:5.1.11.RELEASE:compile
[WARNING] io.searchbox:jest-common:jar:6.3.1:compile
[WARNING] org.springframework.boot:spring-boot-autoconfigure:jar:2.1.10.RELEASE:compile
[WARNING] com.google.code.findbugs:jsr305:jar:3.0.2:compile
[WARNING] org.assertj:assertj-core:jar:3.11.1:test
[WARNING] org.springframework.data:spring-data-elasticsearch:jar:3.1.12.RELEASE:compile
[WARNING] org.springframework:spring-context:jar:5.1.11.RELEASE:compile
[WARNING] org.springframework:spring-webmvc:jar:5.1.11.RELEASE:compile
[WARNING] org.springframework:spring-core:jar:5.1.11.RELEASE:compile
[WARNING] org.zalando:problem:jar:0.23.0:compile
[WARNING] org.mockito:mockito-core:jar:2.23.4:test
[WARNING] org.springframework.security:spring-security-web:jar:5.1.7.RELEASE:compile
[WARNING] org.keycloak:keycloak-spring-security-adapter:jar:4.6.0.Final:compile
[WARNING] org.keycloak:keycloak-core:jar:4.6.0.Final:compile
[WARNING] junit:junit:jar:4.12:test
[WARNING] jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[WARNING] org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.27:compile
[WARNING] javax.persistence:javax.persistence-api:jar:2.2:compile
[WARNING] org.zalando:jackson-datatype-problem:jar:0.23.0:compile
这是未使用的未声明的:
[WARNING] Unused declared dependencies found:
[WARNING] org.springframework.boot:spring-boot-starter-data-jpa:jar:2.1.10.RELEASE:compile
[WARNING] org.springframework.boot:spring-boot-starter-web:jar:2.1.10.RELEASE:compile
[WARNING] org.springframework.boot:spring-boot-starter-data-elasticsearch:jar:2.1.10.RELEASE:compile
[WARNING] org.springframework.boot:spring-boot-starter-security:jar:2.1.10.RELEASE:compile
[WARNING] org.projectlombok:lombok:jar:1.18.10:compile
[WARNING] org.springdoc:springdoc-openapi-ui:jar:1.5.1:compile
[WARNING] org.springdoc:springdoc-openapi-security:jar:1.5.1:compile
[WARNING] org.mapstruct:mapstruct-processor:jar:1.3.0.Final:provided
[WARNING] org.springframework.boot:spring-boot-configuration-processor:jar:2.1.10.RELEASE:provided
[WARNING] org.springframework.boot:spring-boot-starter-test:jar:2.1.10.RELEASE:test
[WARNING] com.github.vanroy:spring-boot-starter-data-jest:jar:3.2.5.RELEASE:compile
[WARNING] de.dentrassi.elasticsearch:log4j2-mock:jar:0.0.1:runtime
[WARNING] org.springframework.boot:spring-boot-starter-actuator:jar:2.1.10.RELEASE:compile
[WARNING] com.stripe:stripe-java:jar:19.26.0:compile
[WARNING] org.keycloak:keycloak-spring-boot-starter:jar:4.6.0.Final:compile
[WARNING] mysql:mysql-connector-java:jar:8.0.18:compile
[WARNING] org.springframework.boot:spring-boot-starter-undertow:jar:2.1.10.RELEASE:compile
[WARNING] org.springframework.boot:spring-boot-devtools:jar:2.1.10.RELEASE:compile
[WARNING] com.h2database:h2:jar:1.4.200:compile
还有树:
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.1.10.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:2.1.10.RELEASE:compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.9.4:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.1.10.RELEASE:compile
[INFO] | | +- com.zaxxer:HikariCP:jar:3.2.0:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:5.1.11.RELEASE:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.3:compile
[INFO] | +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] | | \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.3.13.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.3.Final:compile
[INFO] | | +- javax.persistence:javax.persistence-api:jar:2.2:compile
[INFO] | | +- org.javassist:javassist:jar:3.23.2-GA:compile
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.9.16:compile
[INFO] | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | +- org.jboss:jandex:jar:2.0.5.Final:compile
[INFO] | | +- com.fasterxml:classmate:jar:1.4.0:compile
[INFO] | | +- org.dom4j:dom4j:jar:2.1.1:compile
[INFO] | | +- org.hibernate.common:hibernate-commons-annotations:jar:5.0.4.Final:compile
[INFO] | | \- org.glassfish.jaxb:jaxb-runtime:jar:2.3.1:compile
[INFO] | | +- org.glassfish.jaxb:txw2:jar:2.3.1:compile
[INFO] | | +- com.sun.istack:istack-commons-runtime:jar:3.0.7:compile
[INFO] | | +- org.jvnet.staxex:stax-ex:jar:1.8:compile
[INFO] | | \- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.15:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:2.1.12.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:2.1.12.RELEASE:compile
[INFO] | | +- org.springframework:spring-orm:jar:5.1.11.RELEASE:compile
[INFO] | | +- org.springframework:spring-context:jar:5.1.11.RELEASE:compile
[INFO] | | +- org.springframework:spring-tx:jar:5.1.11.RELEASE:compile
[INFO] | | \- org.springframework:spring-beans:jar:5.1.11.RELEASE:compile
[INFO] | \- org.springframework:spring-aspects:jar:5.1.11.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.1.10.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.1.10.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.10.RELEASE:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.11.2:compile
[INFO] | | | \- org.slf4j:jul-to-slf4j:jar:1.7.29:compile
[INFO] | | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.23:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.1.10.RELEASE:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.10:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.10:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.10:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.1.10.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.27:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.27:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.27:compile
[INFO] | +- org.hibernate.validator:hibernate-validator:jar:6.0.18.Final:compile
[INFO] | +- org.springframework:spring-web:jar:5.1.11.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:5.1.11.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.1.11.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-elasticsearch:jar:2.1.10.RELEASE:compile
[INFO] | \- org.springframework.data:spring-data-elasticsearch:jar:3.1.12.RELEASE:compile
[INFO] | +- joda-time:joda-time:jar:2.10.5:compile
[INFO] | +- org.elasticsearch.client:transport:jar:6.4.3:compile
[INFO] | | +- org.elasticsearch.plugin:reindex-client:jar:6.4.3:compile
[INFO] | | | \- org.elasticsearch.client:elasticsearch-rest-client:jar:6.4.3:compile
[INFO] | | +- org.elasticsearch.plugin:lang-mustache-client:jar:6.4.3:compile
[INFO] | | | \- com.github.spullara.mustache.java:compiler:jar:0.9.3:compile
[INFO] | | +- org.elasticsearch.plugin:percolator-client:jar:6.4.3:compile
[INFO] | | +- org.elasticsearch.plugin:parent-join-client:jar:6.4.3:compile
[INFO] | | \- org.elasticsearch.plugin:rank-eval-client:jar:6.4.3:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.9.10:compile
[INFO] | \- org.elasticsearch.plugin:transport-netty4-client:jar:6.4.3:compile
[INFO] | +- io.netty:netty-buffer:jar:4.1.43.Final:compile
[INFO] | +- io.netty:netty-codec:jar:4.1.43.Final:compile
[INFO] | +- io.netty:netty-codec-http:jar:4.1.43.Final:compile
[INFO] | +- io.netty:netty-common:jar:4.1.43.Final:compile
[INFO] | +- io.netty:netty-handler:jar:4.1.43.Final:compile
[INFO] | +- io.netty:netty-resolver:jar:4.1.43.Final:compile
[INFO] | \- io.netty:netty-transport:jar:4.1.43.Final:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.1.10.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:5.1.11.RELEASE:compile
[INFO] | +- org.springframework.security:spring-security-config:jar:5.1.7.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-web:jar:5.1.7.RELEASE:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.10:compile (optional)
[INFO] +- org.mapstruct:mapstruct:jar:1.3.0.Final:compile
[INFO] +- org.springdoc:springdoc-openapi-ui:jar:1.5.1:compile
[INFO] | +- org.springdoc:springdoc-openapi-webmvc-core:jar:1.5.1:compile
[INFO] | +- org.webjars:swagger-ui:jar:3.37.2:compile
[INFO] | \- org.webjars:webjars-locator-core:jar:0.35:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.8.1:compile
[INFO] | \- org.apache.commons:commons-compress:jar:1.9:compile
[INFO] +- org.springdoc:springdoc-openapi-security:jar:1.5.1:compile
[INFO] | +- org.springdoc:springdoc-openapi-common:jar:1.5.1:compile
[INFO] | | +- io.swagger.core.v3:swagger-models:jar:2.1.6:compile
[INFO] | | +- io.swagger.core.v3:swagger-annotations:jar:2.1.6:compile
[INFO] | | +- io.swagger.core.v3:swagger-integration:jar:2.1.6:compile
[INFO] | | | \- io.swagger.core.v3:swagger-core:jar:2.1.6:compile
[INFO] | | | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:compile
[INFO] | | | | \- jakarta.activation:jakarta.activation-api:jar:1.2.1:compile
[INFO] | | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.9.10:compile
[INFO] | | | \- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[INFO] | | \- io.github.classgraph:classgraph:jar:4.8.69:compile
[INFO] | \- org.springframework.security:spring-security-core:jar:5.1.7.RELEASE:compile
[INFO] +- org.mapstruct:mapstruct-processor:jar:1.3.0.Final:provided
[INFO] +- org.springframework.boot:spring-boot-configuration-processor:jar:2.1.10.RELEASE:provided
[INFO] +- io.github.jhipster:jhipster-framework:jar:3.9.0:compile
[INFO] | +- org.springframework:spring-context-support:jar:5.1.11.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.10.RELEASE:compile
[INFO] | \- net.logstash.logback:logstash-logback-encoder:jar:6.3:compile
[INFO] +- com.google.guava:guava:jar:28.1-jre:compile
[INFO] | +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] | +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] | +- org.checkerframework:checker-qual:jar:2.8.1:compile
[INFO] | +- com.google.errorprone:error_prone_annotations:jar:2.3.2:compile
[INFO] | +- com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.18:compile
[INFO] +- org.zalando:problem-spring-web:jar:0.25.2:compile
[INFO] | +- org.zalando:problem-violations:jar:0.25.2:compile
[INFO] | +- org.zalando:problem-spring-common:jar:0.25.2:compile
[INFO] | +- org.apiguardian:apiguardian-api:jar:1.1.0:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.29:compile
[INFO] | +- org.zalando:problem:jar:0.23.0:compile
[INFO] | +- org.zalando:jackson-datatype-problem:jar:0.23.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.10.1:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.10:compile
[INFO] | +- org.zalando:faux-pas:jar:0.8.0:compile
[INFO] | \- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] +- org.apache.kafka:kafka-clients:jar:2.0.1:compile
[INFO] | +- org.lz4:lz4-java:jar:1.4.1:compile
[INFO] | \- org.xerial.snappy:snappy-java:jar:1.1.7.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.1.10.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.1.10.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.1.10.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.3:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.2:test
[INFO] | | \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | +- org.assertj:assertj-core:jar:3.11.1:test
[INFO] | +- org.mockito:mockito-core:jar:2.23.4:test
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.9.16:test
[INFO] | | \- org.objenesis:objenesis:jar:2.6:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-core:jar:5.1.11.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.1.11.RELEASE:compile
[INFO] | +- org.springframework:spring-test:jar:5.1.11.RELEASE:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.6.3:test
[INFO] +- commons-io:commons-io:jar:2.6:compile
[INFO] +- com.github.vanroy:spring-boot-starter-data-jest:jar:3.2.5.RELEASE:compile
[INFO] | +- com.github.vanroy:spring-data-jest:jar:3.2.5.RELEASE:compile
[INFO] | | +- org.elasticsearch:elasticsearch:jar:6.4.3:compile
[INFO] | | | +- org.elasticsearch:elasticsearch-core:jar:6.4.3:compile
[INFO] | | | +- org.elasticsearch:elasticsearch-secure-sm:jar:6.4.3:compile
[INFO] | | | +- org.elasticsearch:elasticsearch-x-content:jar:6.4.3:compile
[INFO] | | | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.9.10:compile
[INFO] | | | | \- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.9.10:compile
[INFO] | | | +- org.apache.lucene:lucene-core:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-analyzers-common:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-backward-codecs:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-grouping:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-highlighter:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-join:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-memory:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-misc:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-queries:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-queryparser:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-sandbox:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-spatial:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-spatial-extras:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-spatial3d:jar:7.4.0:compile
[INFO] | | | +- org.apache.lucene:lucene-suggest:jar:7.4.0:compile
[INFO] | | | +- org.elasticsearch:elasticsearch-cli:jar:6.4.3:compile
[INFO] | | | | \- net.sf.jopt-simple:jopt-simple:jar:5.0.2:compile
[INFO] | | | +- com.carrotsearch:hppc:jar:0.7.1:compile
[INFO] | | | +- com.tdunning:t-digest:jar:3.2:compile
[INFO] | | | \- org.elasticsearch:jna:jar:4.5.1:compile
[INFO] | | \- io.searchbox:jest:jar:6.3.1:compile
[INFO] | | +- io.searchbox:jest-common:jar:6.3.1:compile
[INFO] | | +- org.apache.httpcomponents:httpcore-nio:jar:4.4.12:compile
[INFO] | | \- org.apache.httpcomponents:httpasyncclient:jar:4.1.4:compile
[INFO] | +- net.java.dev.jna:jna:jar:4.5.2:compile
[INFO] | \- org.apache.logging.log4j:log4j-api:jar:2.11.2:compile
[INFO] +- de.dentrassi.elasticsearch:log4j2-mock:jar:0.0.1:runtime
[INFO] +- com.google.maps:google-maps-services:jar:0.10.2:compile
[INFO] | +- com.squareup.okhttp3:okhttp:jar:3.14.4:compile
[INFO] | | \- com.squareup.okio:okio:jar:1.17.2:compile
[INFO] | \- com.google.code.gson:gson:jar:2.8.6:compile
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.1.10.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.1.10.RELEASE:compile
[INFO] | | \- org.springframework.boot:spring-boot-actuator:jar:2.1.10.RELEASE:compile
[INFO] | \- io.micrometer:micrometer-core:jar:1.1.8:compile
[INFO] | +- org.hdrhistogram:HdrHistogram:jar:2.1.9:compile
[INFO] | \- org.latencyutils:LatencyUtils:jar:2.0.3:compile
[INFO] +- com.stripe:stripe-java:jar:19.26.0:compile
[INFO] +- org.keycloak:keycloak-spring-boot-starter:jar:4.6.0.Final:compile
[INFO] | +- org.keycloak:keycloak-spring-boot-2-adapter:jar:4.6.0.Final:compile
[INFO] | | +- org.keycloak:keycloak-spring-boot-adapter-core:jar:4.6.0.Final:compile
[INFO] | | \- org.keycloak:keycloak-core:jar:4.6.0.Final:compile
[INFO] | | +- org.keycloak:keycloak-common:jar:4.6.0.Final:compile
[INFO] | | \- org.bouncycastle:bcpkix-jdk15on:jar:1.60:compile
[INFO] | +- org.keycloak:keycloak-authz-client:jar:4.6.0.Final:compile
[INFO] | | \- org.apache.httpcomponents:httpclient:jar:4.5.10:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.4.12:compile
[INFO] | | \- commons-codec:commons-codec:jar:1.11:compile
[INFO] | +- org.keycloak:spring-boot-container-bundle:jar:4.6.0.Final:compile
[INFO] | \- org.keycloak:keycloak-spring-security-adapter:jar:4.6.0.Final:compile
[INFO] | +- org.keycloak:keycloak-adapter-spi:jar:4.6.0.Final:compile
[INFO] | +- org.keycloak:keycloak-adapter-core:jar:4.6.0.Final:compile
[INFO] | \- org.bouncycastle:bcprov-jdk15on:jar:1.60:compile
[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.3.2:test
[INFO] | +- org.opentest4j:opentest4j:jar:1.1.1:test
[INFO] | \- org.junit.platform:junit-platform-commons:jar:1.3.2:test
[INFO] +- mysql:mysql-connector-java:jar:8.0.18:compile
[INFO] +- org.springframework.boot:spring-boot-starter-undertow:jar:2.1.10.RELEASE:compile
[INFO] | +- io.undertow:undertow-core:jar:2.0.27.Final:compile
[INFO] | | +- org.jboss.xnio:xnio-api:jar:3.3.8.Final:compile
[INFO] | | \- org.jboss.xnio:xnio-nio:jar:3.3.8.Final:runtime
[INFO] | +- io.undertow:undertow-servlet:jar:2.0.27.Final:compile
[INFO] | | \- org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec:jar:1.0.2.Final:compile
[INFO] | +- io.undertow:undertow-websockets-jsr:jar:2.0.27.Final:compile
[INFO] | | \- org.jboss.spec.javax.websocket:jboss-websocket-api_1.1_spec:jar:1.1.4.Final:compile
[INFO] | +- javax.servlet:javax.servlet-api:jar:4.0.1:compile
[INFO] | \- org.glassfish:javax.el:jar:3.0.0:compile
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:2.1.10.RELEASE:compile (optional)
[INFO] | \- org.springframework.boot:spring-boot:jar:2.1.10.RELEASE:compile
[INFO] \- com.h2database:h2:jar:1.4.200:compile
【问题讨论】:
你能发布mvn dependency:tree
和mvn dependency:analyze
的输出吗?即使是 sn-ps 或编辑 com.hasan.employer
条目也有助于提供答案。
嗨,我发布了你想要的结果
最重要的部分是不存在 pom.xml 文件......并且在 spring boot 中说不需要的东西是一种有趣的方法吗?你知道它什么时候用过吗?
这是我的问题的一部分,我如何验证是否使用了某些东西?例如,我们的项目中使用了 lombok,但命令说它未使用...
【参考方案1】:
您应该了解 Maven 的依赖范围: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#dependency-scope
例如,对于 Lombok,应使用 provided
范围,详细说明 here。
【讨论】:
我会看看这个。谢谢。一个问题是我应该决定排除或不排除依赖项的标准是什么? 没有酸性测试。 什么意思? 我的意思是你只需要知道。例如,我看到您将 H2 作为依赖项。您正在使用它进行单元测试,对吗?那么范围应该是test
,因为您的应用在运行时不需要它。我真的无法比 apache 手册更好地解释它。但是,除非您遇到问题,否则我认为您不应该排除任何东西。以上是关于识别 Maven 中的依赖项的主要内容,如果未能解决你的问题,请参考以下文章
为啥即使我的 maven 依赖项中有第三方依赖项,也只需要 OSGi 容器中的第三方依赖项?