java fileversioninfo_java – 无法处理配置类的导入候选项

我有一个Spring Boot项目,我可以在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 Locating auto-configuration candidates所述,但这并没有解决问题:

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\

el.dorado.AppConfig

这是项目pom.xml:

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

4.0.0

el.dorado

ElDorado

jar

1.0-SNAPSHOT

ElDorado

http://maven.apache.org

4.12

org.springframework.boot

spring-boot-starter-parent

1.4.0.RELEASE

org.springframework.boot

spring-boot-starter

org.springframework.boot

spring-boot-starter-data-jpa

com.h2database

h2

junit

junit

${junit.version}

test

maven-assembly-plugin

el.dorado.App

true

jar-with-dependencies

make-assembly

package

single

org.jacoco

jacoco-maven-plugin

jacoco-initialize

prepare-agent

jacoco-site

verify

report

解决方法:

我只想弄清楚,我应该一直使用Spring Boot maven plugin.现在我的pom.xml的构建部分如下所示:

org.springframework.boot

spring-boot-maven-plugin

true

dz.lab.jpmtask.App

repackage

org.jacoco

jacoco-maven-plugin

jacoco-initialize

prepare-agent

jacoco-site

verify

report

我使用mvn clean包和java -jar target / myproject.jar构建项目,它就像一个魅力.

标签:java,spring,spring-boot,maven,spring-data-jpa

来源: https://codeday.me/bug/20190926/1817967.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值