I am getting "Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled." Solution for this?

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

I am getting "Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled." Solution for this?

问题

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

我的文件夹结构:
My Console:
.   ____          _            __ _ _
/\ / 大块文本'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | 大块文本'_ | 大块文本'| | 大块文本'_ \/ _` | \ \ \ \
\/  大块文本)| 大块文本'| | 大块文本'| | 大块文本'|| (_| |  ) ) ) )
'  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::        (v2.3.2.RELEASE)
2020-08-09 18:04:58.332  INFO 16828 --- [           main] com.api.main.ProjectApiApplication       : Starting ProjectApiApplication on LAPTOP-I4F37P4O with PID 16828 (C:\Users\mitad\Documents\STS_Workspace\ProjectAPI\target\classes started by mitad in C:\Users\mitad\Documents\STS_Workspace\ProjectAPI)
2020-08-09 18:04:58.334  INFO 16828 --- [           main] com.api.main.ProjectApiApplication       : No active profile set, falling back to default profiles: default
2020-08-09 18:04:58.866  INFO 16828 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-08-09 18:04:58.872  INFO 16828 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-08-09 18:04:58.872  INFO 16828 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.37]
2020-08-09 18:04:58.928  INFO 16828 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-08-09 18:04:58.928  INFO 16828 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 566 ms
2020-08-09 18:04:59.039  INFO 16828 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-08-09 18:04:59.148  INFO 16828 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-08-09 18:04:59.155  INFO 16828 --- [           main] com.api.main.ProjectApiApplication       : Started ProjectApiApplication in 1.04 seconds (JVM running for 1.534)
2020-08-09 18:04:59.231  WARN 16828 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springApplicationAdminRegistrar' defined in class path resource [org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Admin,name=SpringApplication
2020-08-09 18:04:59.233  INFO 16828 --- [           main] ConditionEvaluationReportLoggingListener : 
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-08-09 18:04:59.245 ERROR 16828 --- [           main] o.s.boot.SpringApplication               : Application run failed
java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:798) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
at com.api.main.ProjectApiApplication.main(ProjectApiApplication.java:26) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springApplicationAdminRegistrar' defined in class path resource [org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Admin,name=SpringApplication
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1794) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5
<details>
<summary>英文:</summary>
[My folder structure][1]
[1]: https://i.stack.imgur.com/avp85.png
My Console:
.   ____          _            __ _ _
/\\ / ___&#39;_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | &#39;_ | &#39;_| | &#39;_ \/ _` | \ \ \ \
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
&#39;  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::        (v2.3.2.RELEASE)
2020-08-09 18:04:58.332  INFO 16828 --- [           main] com.api.main.ProjectApiApplication       : Starting ProjectApiApplication on LAPTOP-I4F37P4O with PID 16828 (C:\Users\mitad\Documents\STS_Workspace\ProjectAPI\target\classes started by mitad in C:\Users\mitad\Documents\STS_Workspace\ProjectAPI)
2020-08-09 18:04:58.334  INFO 16828 --- [           main] com.api.main.ProjectApiApplication       : No active profile set, falling back to default profiles: default
2020-08-09 18:04:58.866  INFO 16828 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-08-09 18:04:58.872  INFO 16828 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-08-09 18:04:58.872  INFO 16828 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.37]
2020-08-09 18:04:58.928  INFO 16828 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-08-09 18:04:58.928  INFO 16828 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 566 ms
2020-08-09 18:04:59.039  INFO 16828 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService &#39;applicationTaskExecutor&#39;
2020-08-09 18:04:59.148  INFO 16828 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path &#39;&#39;
2020-08-09 18:04:59.155  INFO 16828 --- [           main] com.api.main.ProjectApiApplication       : Started ProjectApiApplication in 1.04 seconds (JVM running for 1.534)
2020-08-09 18:04:59.231  WARN 16828 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;springApplicationAdminRegistrar&#39; defined in class path resource [org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Admin,name=SpringApplication
2020-08-09 18:04:59.233  INFO 16828 --- [           main] ConditionEvaluationReportLoggingListener : 
Error starting ApplicationContext. To display the conditions report re-run your application with &#39;debug&#39; enabled.
2020-08-09 18:04:59.245 ERROR 16828 --- [           main] o.s.boot.SpringApplication               : Application run failed
java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:798) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
at com.api.main.ProjectApiApplication.main(ProjectApiApplication.java:26) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;springApplicationAdminRegistrar&#39; defined in class path resource [org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Admin,name=SpringApplication
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1794) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.annotation.AnnotationConfigApplicationContext.&lt;init&gt;(AnnotationConfigApplicationContext.java:89) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at com.api.main.ProjectApiApplication.run(ProjectApiApplication.java:19) [classes/:na]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
... 5 common frames omitted
Caused by: javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Admin,name=SpringApplication
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437) ~[na:1.8.0_202]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898) ~[na:1.8.0_202]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966) ~[na:1.8.0_202]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900) ~[na:1.8.0_202]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324) ~[na:1.8.0_202]
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) ~[na:1.8.0_202]
at org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar.afterPropertiesSet(SpringApplicationAdminMXBeanRegistrar.java:129) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 17 common frames omitted
2020-08-09 18:04:59.362  INFO 16828 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService &#39;applicationTaskExecutor&#39;
ConnectToDatabaseImpl:
package com.api.databse.service;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
@Service(&quot;connectTodb&quot;)
public class ConnectToDatabaseImpl implements ConnectToDatabase{
@Value(&quot;${jdbc.username:default}&quot;)
private String userName;
@Value(&quot;${jdbc.password:default}&quot;)
private String password;
@Autowired
private Environment environment;
@Override
public void getDatabseDetails() {
try{  		
Class.forName(environment.getProperty(&quot;jdbc.driverClassName&quot;));  
Connection connection = DriverManager.getConnection(  
environment.getProperty(&quot;jdbc.url&quot;),userName,password);  
Statement stmt=connection.createStatement();  
ResultSet resultSet = stmt.executeQuery(environment.getProperty(&quot;jdbc.SQLQuery&quot;));  
while(resultSet.next())  
System.out.println(resultSet.getInt(1)+&quot;  &quot;+resultSet.getString(2)+&quot;  &quot;+resultSet.getString(3));
connection.close();
}
catch(SQLException se){ 
se.printStackTrace();
}  
catch(ClassNotFoundException ce) {
ce.printStackTrace();
}
}  
}
AppConfig:
package com.api.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@Configuration
@ComponentScan(basePackages=&quot;com.api&quot;)
@PropertySource(value= {&quot;classpath:application.properties&quot;})
public class AppConfig {	
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
ProjectApiApplication:
package com.api.main;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import com.api.configuration.AppConfig;
import com.api.databse.service.ConnectToDatabase;
@SpringBootApplication
@EnableAutoConfiguration
public class ProjectApiApplication implements CommandLineRunner{
@Override
public void run(String...args) throws Exception{
AbstractApplicationContext  context = new AnnotationConfigApplicationContext(AppConfig.class);
ConnectToDatabase connection = (ConnectToDatabase)context.getBean(&quot;connectTodb&quot;);
connection.getDatabseDetails();
context.close();
}
public static void main(String[] args) {
SpringApplication.run(ProjectApiApplication.class, args);
}
}
pom.xml:
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;parent&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
&lt;version&gt;2.3.2.RELEASE&lt;/version&gt;
&lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
&lt;/parent&gt;
&lt;groupId&gt;com.example&lt;/groupId&gt;
&lt;artifactId&gt;ProjectAPI&lt;/artifactId&gt;
&lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
&lt;name&gt;ProjectAPI&lt;/name&gt;
&lt;description&gt;Project for Spring Boot and API Calling&lt;/description&gt;
&lt;properties&gt;
&lt;java.version&gt;1.8&lt;/java.version&gt;
&lt;/properties&gt;
&lt;dependencies&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.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;exclusions&gt;
&lt;exclusion&gt;
&lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
&lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
&lt;/exclusion&gt;
&lt;/exclusions&gt;
&lt;/dependency&gt;
&lt;!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --&gt;
&lt;dependency&gt;
&lt;groupId&gt;mysql&lt;/groupId&gt;
&lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
&lt;version&gt;8.0.21&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- https://mvnrepository.com/artifact/org.springframework/spring-context --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-context&lt;/artifactId&gt;
&lt;version&gt;5.2.6.RELEASE&lt;/version&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;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;
&lt;/project&gt;
</details>
# 答案1
**得分**: 2
删除`spring-context`依赖 - 你已经有了Spring Boot的父级依赖,一般情况下不要引入不同版本的Spring依赖。
**重要提示:** 不要在实现CommandLineRunner接口的类内部运行Spring Boot的主程序。通常,将所有相关代码从`run`方法中提取出来,然后在主程序中使用它,然后移除对CommandLineRunner的实现,以确保一切正常运行。
此外,你不需要使用`EnableAutoConfiguration`注解,因为`@SpringBootApplication`注解已经包含了它。
你也不需要使用`PropertySourcesPlaceholderConfigurer`,因为Spring Boot已经提供了一个相应的功能。建议查阅Spring Boot的文档以获取更多信息。
另外,在Spring Boot中,如果你在`application.properties`文件中提供了数据库连接属性,数据库连接会自动配置,示例如下:

spring.datasource.url=jdbc:mysql://localhost:3306/yourDatabaseName?useSSL=false
spring.datasource.username=yourDatabaseUsername
spring.datasource.password=yourDatabasePassword


这里有一篇关于Spring JDBC的博客文章示例:https://javamondays.com/simple-java-jdbc-example/
<details>
<summary>英文:</summary>
Remove `spring-context` dependency - you have the spring boot parent, and dont introduce dependencies of spring with a different version in general.
**IMPORTANT:** don&#39;t run SpringBoot main inside of CommandLineRunner implementing class. In general grab all that stuff from `run` method and use it in main and remove implements CommandLineRunner for everything to work.
Also you don&#39;t need `EnableAutoConfiguration` as `@SpringBootApplication` annotation includes it
You also don&#39;t need `PropertySourcesPlaceholderConfigurer` as Spring Boot provides one. Consider reading documentation on Spring Boot.
Additionally in SpringBoot connection to database is done automatically if you provide properties in `application.properties` file - like so:
spring.datasource.url=jdbc:mysql://localhost:3306/yourDatabaseName?useSSL=false
spring.datasource.username=yourDatabaseUsername
spring.datasource.password=yourDatabasePassword
here is a blog post example for Spring JDBC https://javamondays.com/simple-java-jdbc-example/
</details>
# 答案2
**得分**: 0
此外,Spring Boot 正在创建容器,您会收到此错误,因为有两个上下文在不同的层次结构中运行。在 ProjectApiApplication 中添加以下字段以检索上下文:
```java
@Autowired
private ApplicationContext context;
英文:

In addition, Spring Boot is creating the container, you get this error as you have 2 contexts running not in the same hierarchy. Add this field in ProjectApiApplication to retrieve the context:

@Autowired
private ApplicationContext context;

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

发表评论

匿名网友

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

确定