SpringBoot应用程序在添加依赖项时启动失败

huangapple go评论75阅读模式
英文:

SpringBoot Application fails startup when adding dependency

问题

以下是您提供的内容的翻译:

我有一个已经运行正常的 SpringBoot 应用程序。然后,我创建了一个 Java 库——一个独立的仓库,只包含静态 Java 代码,没有主类。我的库作为 GitHub Maven 包部署。

然后,我继续在本地 Maven 设置中设置了我的 GitHub packages 仓库,并将依赖项添加到我的原始 SpringBoot 应用程序中。导入过程成功,我的库的 Jar 文件位于类路径中,编译和构建都成功。

接下来发生的是我现在运行应用程序,然后我得到以下堆栈跟踪:

02:36:51.110 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [<redacted list of classpath dependencies, including my new library>]
02:36:51.223 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:161)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:102)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:68)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:80)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
	at my.org.transfer.TransferServicesApiApplication.main(TransferServicesApiApplication.java:18)

Process finished with exit code 1

我不确定还有什么别的尝试,我已经搜索了一整晚,但没有找到答案。这是我的应用程序的 pom.xml

<!-- 应用程序的 pom.xml -->
<project>
    <!-- ... -->
    <dependencies>
        <!-- my library import -->
        <dependency>
            <groupId>my.org</groupId>
            <artifactId>mylibrary</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <!-- ... -->
    </dependencies>
    <!-- ... -->
</project>

这是我的库的 pom.xml

<!-- 库的 pom.xml -->
<project>
    <!-- ... -->
    <dependencies>
        <!-- ... -->
    </dependencies>
    <distributionManagement>
        <repository>
            <id>github</id>
            <name>Github Packages</name>
            <url>https://maven.pkg.github.com/my-org/library-repo</url>
        </repository>
    </distributionManagement>
    <!-- ... -->
</project>

感谢您的帮助。

编辑:将应用程序的 pom.xml 中的 spring-boot-starter-parent 版本设置为与库 pom.xml 中的版本相匹配。没有变化。

编辑 2:这是 mvn dependency:tree 的输出(注入库的依赖项在底部):

[INFO] my.org.hopscotchtrading:transfer-services-api:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.3.4.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot:jar:2.3.4.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-context:jar:5.2.9.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.3.4.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.3.4.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.13.3:compile
[INFO] |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.13.3:compile
[INFO] |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.30:compile
[INFO] |  +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] |  +- org.springframework:spring-core:jar:5.2.9.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-jcl:jar:5.2.9.RELEASE:compile
[INFO] |  \- org.yaml:snakeyaml:jar:1.26:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.3.4.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.3.4.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.3.4.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] |  +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:test
[INFO] |  |  \- jakarta.activation:jakarta.activation-api:jar:1.2.2:test
[INFO] |  +- org.assertj:assertj-core:jar:3.16.1

<details>
<summary>英文:</summary>

I have an existing SpringBoot Application that was running with no issue. I then created a Java library—a standalone repository with only static Java code, no main class. My library is deployed as a GitHub Maven package.

I then proceeded with setting up my GitHub packages repository in my local Maven settings and added the dependency to my original SpringBoot application. The import process is successful, my library&#39;s Jar is in the classpath and compilation and build are successful.

What happens next is I run the application now, and I get the following stacktrace:

02:36:51.110 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [<redacted list of classpath dependencies, including my new library>]
02:36:51.223 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:161)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:102)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:68)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:80)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at my.org.transfer.TransferServicesApiApplication.main(TransferServicesApiApplication.java:18)

Process finished with exit code 1

I&#39;m not sure what else to try and a night of Googling lead me nowhere.
This is my application&#39;s `pom.xml`:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>my.org</groupId>
<artifactId>appname</artifactId>
<version>0.0.1-SNAPSHOT</version>

&lt;properties&gt;
	&lt;java.version&gt;1.8&lt;/java.version&gt;
&lt;/properties&gt;

&lt;dependencies&gt;
    &lt;dependency&gt; &lt;!-- my library import --&gt;
        &lt;groupId&gt;my.org&lt;/groupId&gt;
        &lt;artifactId&gt;mylibrary&lt;/artifactId&gt;
        &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
		&lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
		&lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
		&lt;scope&gt;test&lt;/scope&gt;
	&lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
        &lt;artifactId&gt;lombok&lt;/artifactId&gt;
        &lt;version&gt;1.18.12&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;io.jsonwebtoken&lt;/groupId&gt;
        &lt;artifactId&gt;jjwt&lt;/artifactId&gt;
        &lt;version&gt;0.9.1&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;joda-time&lt;/groupId&gt;
        &lt;artifactId&gt;joda-time&lt;/artifactId&gt;
        &lt;version&gt;2.10.6&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.jetbrains&lt;/groupId&gt;
        &lt;artifactId&gt;annotations&lt;/artifactId&gt;
        &lt;version&gt;19.0.0&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;commons-io&lt;/groupId&gt;
        &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
        &lt;version&gt;2.7&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;commons-codec&lt;/groupId&gt;
        &lt;artifactId&gt;commons-codec&lt;/artifactId&gt;
        &lt;version&gt;1.14&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;commons-collections&lt;/groupId&gt;
        &lt;artifactId&gt;commons-collections&lt;/artifactId&gt;
        &lt;version&gt;3.2.2&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;commons-lang&lt;/groupId&gt;
        &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
        &lt;version&gt;2.4&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
        &lt;version&gt;5.2.7.RELEASE&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.maven.surefire&lt;/groupId&gt;
        &lt;artifactId&gt;surefire-booter&lt;/artifactId&gt;
        &lt;version&gt;2.22.2&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;commons-beanutils&lt;/groupId&gt;
        &lt;artifactId&gt;commons-beanutils&lt;/artifactId&gt;
        &lt;version&gt;1.9.4&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;javax.validation&lt;/groupId&gt;
        &lt;artifactId&gt;validation-api&lt;/artifactId&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;io.springfox&lt;/groupId&gt;
        &lt;artifactId&gt;springfox-swagger2&lt;/artifactId&gt;
        &lt;version&gt;2.9.2&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;io.springfox&lt;/groupId&gt;
        &lt;artifactId&gt;springfox-swagger-ui&lt;/artifactId&gt;
        &lt;version&gt;2.9.2&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.influxdb&lt;/groupId&gt;
        &lt;artifactId&gt;influxdb-java&lt;/artifactId&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;

&lt;build&gt;
	&lt;plugins&gt;
		&lt;plugin&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
			&lt;configuration&gt;
                &lt;goalPrefix&gt;formatter&lt;/goalPrefix&gt;
				&lt;executable&gt;true&lt;/executable&gt;
			&lt;/configuration&gt;
		&lt;/plugin&gt;
		&lt;plugin&gt;
			&lt;groupId&gt;net.revelc.code.formatter&lt;/groupId&gt;
			&lt;artifactId&gt;formatter-maven-plugin&lt;/artifactId&gt;
			&lt;version&gt;2.12.0&lt;/version&gt;
		&lt;/plugin&gt;
	&lt;/plugins&gt;
&lt;/build&gt;

</project>

My library&#39;s `pom.xml`:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>my.org</groupId>
<artifactId>mylibrary</artifactId>
<version>0.0.1-SNAPSHOT</version>

&lt;properties&gt;
	&lt;java.version&gt;1.8&lt;/java.version&gt;
&lt;/properties&gt;

&lt;distributionManagement&gt;
    &lt;repository&gt;
        &lt;id&gt;github&lt;/id&gt;
        &lt;name&gt;Github Packages&lt;/name&gt;
        &lt;url&gt;https://maven.pkg.github.com/my-org/library-repo&lt;/url&gt;
    &lt;/repository&gt;
&lt;/distributionManagement&gt;

&lt;dependencies&gt;
	&lt;dependency&gt;
        &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;
        &lt;artifactId&gt;aws-java-sdk-secretsmanager&lt;/artifactId&gt;
        &lt;version&gt;1.11.793&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
        &lt;artifactId&gt;lombok&lt;/artifactId&gt;
        &lt;version&gt;1.18.12&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.jetbrains&lt;/groupId&gt;
        &lt;artifactId&gt;annotations&lt;/artifactId&gt;
        &lt;version&gt;20.1.0&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
        &lt;artifactId&gt;commons-collections4&lt;/artifactId&gt;
        &lt;version&gt;4.4&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
        &lt;artifactId&gt;spring-cloud-aws-secrets-manager-config&lt;/artifactId&gt;
        &lt;version&gt;2.1.1.RELEASE&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
        &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
        &lt;version&gt;3.10&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;4.13&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.powermock&lt;/groupId&gt;
        &lt;artifactId&gt;powermock-module-junit4&lt;/artifactId&gt;
        &lt;version&gt;2.0.7&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.powermock&lt;/groupId&gt;
        &lt;artifactId&gt;powermock-api-easymock&lt;/artifactId&gt;
        &lt;version&gt;2.0.7&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.powermock&lt;/groupId&gt;
        &lt;artifactId&gt;powermock-api-mockito2&lt;/artifactId&gt;
        &lt;version&gt;2.0.7&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;

&lt;build&gt;
	&lt;plugins&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;net.revelc.code.formatter&lt;/groupId&gt;
            &lt;artifactId&gt;formatter-maven-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.12.0&lt;/version&gt;
        &lt;/plugin&gt;
	&lt;/plugins&gt;
&lt;/build&gt;

</project>

Thanks much.


----------


Edit: set `spring-boot-starter-parent` version in application pom to match the version in the library pom. No changes.


----------

Edit 2: This is the output of `mvn dependency:tree` (my library-injected dependency at the bottom):

[INFO] my.org.hopscotchtrading:transfer-services-api:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.3.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.3.4.RELEASE:compile
[INFO] | | - org.springframework:spring-context:jar:5.2.9.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.3.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:2.3.4.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.13.3:compile
[INFO] | | | - org.apache.logging.log4j:log4j-api:jar:2.13.3:compile
[INFO] | | - org.slf4j:jul-to-slf4j:jar:1.7.30:compile
[INFO] | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | +- org.springframework:spring-core:jar:5.2.9.RELEASE:compile
[INFO] | | - org.springframework:spring-jcl:jar:5.2.9.RELEASE:compile
[INFO] | - org.yaml:snakeyaml:jar:1.26:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.3.4.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.3.4.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.3.4.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] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:test
[INFO] | | - jakarta.activation:jakarta.activation-api:jar:1.2.2:test
[INFO] | +- org.assertj:assertj-core:jar:3.16.1:test
[INFO] | +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] | +- org.junit.jupiter:junit-jupiter:jar:5.6.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-api:jar:5.6.2:test
[INFO] | | | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | | | - org.junit.platform:junit-platform-commons:jar:1.6.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-params:jar:5.6.2:test
[INFO] | | - org.junit.jupiter:junit-jupiter-engine:jar:5.6.2:test
[INFO] | +- org.junit.vintage:junit-vintage-engine:jar:5.6.2:test
[INFO] | | +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] | | +- org.junit.platform:junit-platform-engine:jar:1.6.2:test
[INFO] | | - junit:junit:jar:4.13:test
[INFO] | +- org.mockito:mockito-core:jar:3.3.3:test
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.10.14:compile
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.10.14:test
[INFO] | | - org.objenesis:objenesis:jar:2.6:test
[INFO] | +- org.mockito:mockito-junit-jupiter:jar:3.3.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-test:jar:5.2.9.RELEASE:test
[INFO] | - org.xmlunit:xmlunit-core:jar:2.7.0:test
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.3.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.3.4.RELEASE:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.2:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.2:compile
[INFO] | | - com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.2:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.3.4.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.38:compile
[INFO] | | +- org.glassfish:jakarta.el:jar:3.0.3:compile
[INFO] | | - org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.38:compile
[INFO] | - org.springframework:spring-webmvc:jar:5.2.9.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:5.2.9.RELEASE:compile
[INFO] | - org.springframework:spring-expression:jar:5.2.9.RELEASE:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.12:compile
[INFO] +- io.jsonwebtoken:jjwt:jar:0.9.1:compile
[INFO] | - com.fasterxml.jackson.core:jackson-databind:jar:2.11.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.2:compile
[INFO] | - com.fasterxml.jackson.core:jackson-core:jar:2.11.2:compile
[INFO] +- joda-time:joda-time:jar:2.10.6:compile
[INFO] +- org.jetbrains:annotations:jar:19.0.0:compile
[INFO] +- commons-io:commons-io:jar:2.7:compile
[INFO] +- commons-codec:commons-codec:jar:1.14:compile
[INFO] +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- commons-lang:commons-lang:jar:2.4:compile
[INFO] +- org.springframework:spring-web:jar:5.2.7.RELEASE:compile
[INFO] | - org.springframework:spring-beans:jar:5.2.9.RELEASE:compile
[INFO] +- org.apache.maven.surefire:surefire-booter:jar:2.22.2:compile
[INFO] | - org.apache.maven.surefire:surefire-api:jar:2.22.2:compile
[INFO] | - org.apache.maven.surefire:surefire-logger-api:jar:2.22.2:compile
[INFO] +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] | - commons-logging:commons-logging:jar:1.2:compile
[INFO] +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] +- io.springfox:springfox-swagger2:jar:2.9.2:compile
[INFO] | +- io.swagger:swagger-annotations:jar:1.5.20:compile
[INFO] | +- io.swagger:swagger-models:jar:1.5.20:compile
[INFO] | +- io.springfox:springfox-spi:jar:2.9.2:compile
[INFO] | | - io.springfox:springfox-core:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-schema:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-swagger-common:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-spring-web:jar:2.9.2:compile
[INFO] | +- com.google.guava:guava:jar:20.0:compile
[INFO] | +- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] | +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] | +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO] | - org.mapstruct:mapstruct:jar:1.2.0.Final:compile
[INFO] +- io.springfox:springfox-swagger-ui:jar:2.9.2:compile
[INFO] +- org.influxdb:influxdb-java:jar:2.18:compile
[INFO] | +- com.squareup.retrofit2:retrofit:jar:2.8.1:compile
[INFO] | +- com.squareup.retrofit2:converter-moshi:jar:2.8.1:compile
[INFO] | | - com.squareup.moshi:moshi:jar:1.8.0:compile
[INFO] | +- org.msgpack:msgpack-core:jar:0.8.20:compile
[INFO] | +- com.squareup.okhttp3:okhttp:jar:3.14.9:compile
[INFO] | | - com.squareup.okio:okio:jar:1.17.2:compile
[INFO] | - com.squareup.okhttp3:logging-interceptor:jar:3.14.9:compile
[INFO] - my.org:mylibrary:jar:0.0.1-SNAPSHOT:compile
[INFO] +- com.amazonaws:aws-java-sdk-secretsmanager:jar:1.11.793:compile
[INFO] | +- com.amazonaws:aws-java-sdk-core:jar:1.11.793:compile
[INFO] | | +- org.apache.httpcomponents:httpclient:jar:4.5.12:compile
[INFO] | | | - org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] | | +- software.amazon.ion:ion-java:jar:1.0.2:compile
[INFO] | | - com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.11.2:compile
[INFO] | - com.amazonaws:jmespath-java:jar:1.11.793:compile
[INFO] +- org.apache.commons:commons-collections4:jar:4.4:compile
[INFO] +- org.springframework.cloud:spring-cloud-aws-secrets-manager-config:jar:2.1.1.RELEASE:compile
[INFO] | - org.springframework.cloud:spring-cloud-context:jar:1.3.2.RELEASE:compile
[INFO] | - org.springframework.security:spring-security-crypto:jar:5.3.4.RELEASE:compile
[INFO] - org.apache.commons:commons-lang3:jar:3.10:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.147 s
[INFO] Finished at: 2020-09-19T13:06:54-05:00
[INFO] ------------------------------------------------------------------------


</details>


# 答案1
**得分**: 2

你正在使用不同版本的 spring-boot-starter-parent(2.3.1.RELEASE 和 2.3.4.RELEASE),这可能导致不一致的版本,其中较早或较新的版本可能没有该方法。尝试在应用程序中使用 2.3.4.RELEASE。

【更新】

您仍然在类路径中获得了不一致的 `org.springframework:*` 版本:

```xml
[INFO] |  \- org.springframework:spring-webmvc:jar:5.2.9.RELEASE:compile
[INFO] |     +- org.springframework:spring-aop:jar:5.2.9.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:5.2.9.RELEASE:compile
...
[INFO] +- org.springframework:spring-web:jar:5.2.7.RELEASE:compile

在您的应用程序 pom.xml 文件中,从以下位置删除显式依赖项:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>5.2.7.RELEASE</version>
</dependency>

并且删除来自父级中指定的任何其他依赖项,这样您就可以在依赖项输出中获得所有 5.2.9 版本。

最后,关于 Spring Boot 版本的要求有类似于这里的讨论(链接:https://stackoverflow.com/questions/55498624/java-lang-nosuchmethoderror-org-springframework-boot-builder-springapplicationb),而 spring-cloud-aws-secrets-manager-config 的最新版本是 2.2.4.RELEASE,这让我想到您库的 POM 需要更新为使用最新版本。

英文:

You're using different versions of spring-boot-starter-parent (2.3.1.RELEASE and 2.3.4.RELEASE) which is probably leading to inconsistent versions where the later or earlier don't have the method. Try using 2.3.4.RELEASE in your application.

[Update]

You're still getting inconsistent versions of org.springframework:* on the classpath:

[INFO] |  \- org.springframework:spring-webmvc:jar:5.2.9.RELEASE:compile
[INFO] |     +- org.springframework:spring-aop:jar:5.2.9.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:5.2.9.RELEASE:compile
...
[INFO] +- org.springframework:spring-web:jar:5.2.7.RELEASE:compile

In your application pom.xml remove the explicit dependency from

&lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
            &lt;version&gt;5.2.7.RELEASE&lt;/version&gt;
        &lt;/dependency&gt;

and any other dependency that is specified in the parent so you get all 5.2.9 versions in the dependency output.

Finally, there is discussion like here about requiring specific versions for Spring Boot and the latest version of spring-cloud-aws-secrets-manager-config is 2.2.4.RELEASE which makes me think your library's POM needs to be updated to use the latest.

huangapple
  • 本文由 发表于 2020年9月20日 00:28:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/63970992.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定