구성 클래스에 대한 후보 가져오기를 처리하지 못했습니다.
IntelliJ 내에서 정상적으로 실행할 수 있는 스프링 부트 프로젝트가 있지만 실행 가능한 jar를 패키징하면 실행할 수 없게 됩니다.예외 스택 트레이스를 다음에 나타냅니다.
18:13:55.254 [main] INFO o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@b3d7190: startup date [Wed Sep 07 18:13:55 CEST 2016]; root of context hierarchy
18:13:55.403 [main] WARN o.s.c.a.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [el.dorado.App]; nested exception is java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
18:13:55.414 [main] ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [el.dorado.App]; nested exception is java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:489)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:191)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
at dz.lab.jpmtask.App.main(App.java:33)
Caused by: java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
at org.springframework.util.Assert.notEmpty(Assert.java:276)
at org.springframework.boot.autoconfigure.EnableAutoConfigurationImportSelector.getCandidateConfigurations(EnableAutoConfigurationImportSelector.java:145)
at org.springframework.boot.autoconfigure.EnableAutoConfigurationImportSelector.selectImports(EnableAutoConfigurationImportSelector.java:84)
at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:481)
... 13 common frames omitted
구성은 다음과 같습니다.
@Configuration
@EnableAutoConfiguration
public class AppConfig {
... some beans
}
추가했습니다.META-INF/spring.factories
43.2에서 설명한 바와 같이 프로젝트 리소스 폴더 아래에 있는 자동 구성 후보를 찾습니다. 그러나 이 방법으로는 문제가 해결되지 않았습니다.
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
el.dorado.AppConfig
여기 프로젝트가 있습니다.pom.xml
:
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>el.dorado</groupId>
<artifactId>ElDorado</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>ElDorado</name>
<url>http://maven.apache.org</url>
<properties>
<junit.version>4.12</junit.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>el.dorado.App</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<!--<version>0.7.8-SNAPSHOT</version>-->
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
이제서야 알았어요, 대신 Spring Boot maven 플러그인을 사용했어야 했어요.이제 내 빌드 섹션은pom.xml
외관:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<mainClass>dz.lab.jpmtask.App</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<!--<version>0.7.8-SNAPSHOT</version>-->
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
저는 이 프로젝트를mvn clean package
그리고 나서.java -jar target/myproject.jar
마법처럼 잘 작동하죠
AppConfig에서 주석을 사용하는 것을 잊어버린 것 같습니다.
다음 3개의 주석을 에 추가합니다.AppConfig
클래스:
@Configuration
@EnableWebMvc
@ComponentScan("Scan_Package_Name")
public class AppConfig {
... some beans
}
그리고 또...
구성 클래스 [...]에 대한 후보 가져오기를 처리하지 못했습니다. 중첩된 예외는 java.lang입니다.InlawalStateException:클래스의 메타데이터를 읽을 수 없습니다...
제 오타로 인한 오류입니다.spring.factories
이 경우 루트 예외는
클래스 경로 리소스 [...]가 없으므로 열 수 없습니다.
컴파일 시에 검증할 수 없기 때문에, 이것은 중요한 체크 포인트입니다.
에서 전환했습니다.mvn clean compile assembly:single
로.mvn clean package
오류가 사라졌습니다.
다음과 같이 해결했습니다.
- 삭제하다
spring-boot-maven-plugin
- 음영 플러그인으로 스프링 변압기를 구성합니다. spring parent pom을 참조하십시오.
똑같은 문제가 생겼어.만약 당신도 Tomcat을 사용하고 있다면 청소하는 것이 도움이 되었습니다.
언급URL : https://stackoverflow.com/questions/39375016/failed-to-process-import-candidates-for-configuration-class
'source' 카테고리의 다른 글
XML 태그 속성을 JSON으로 어떻게 표현합니까? (0) | 2023.03.10 |
---|---|
Visual Studio 2015 JSX/ES2015 구문 강조 (0) | 2023.03.10 |
$watch는 초기화 직후에 트리거됩니다.왜요? (0) | 2023.03.10 |
java.sql.SQLException:알 수 없는 시스템 변수 'query_cache_size' (0) | 2023.03.10 |
ASP의 Json()에서 소문자 속성 이름을 강제로 지정합니다.넷 MVC (0) | 2023.03.10 |