No auto configuration classes found in META-IN F/spring.factories. If you are using a custom packaging, make sure that file is correct.

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to proces s import candidates for configuration class [maven.Te...
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to proces
s import candidates for configuration class [maven.Test]; nested exception is ja
va.lang.IllegalArgumentException: No auto configuration classes found in META-IN
F/spring.factories. If you are using a custom packaging, make sure that file is
correct.
        at org.springframework.context.annotation.ConfigurationClassParser.proce
ssDeferredImportSelectors(ConfigurationClassParser.java:556) ~[HelloJava-1.0.jar
:na]
        at org.springframework.context.annotation.ConfigurationClassParser.parse
(ConfigurationClassParser.java:185) ~[HelloJava-1.0.jar:na]
        at org.springframework.context.annotation.ConfigurationClassPostProcesso
r.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:308) ~[Hello
Java-1.0.jar:na]
        at org.springframework.context.annotation.ConfigurationClassPostProcesso
r.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228) ~[
HelloJava-1.0.jar:na]
        at org.springframework.context.support.PostProcessorRegistrationDelegate
.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.ja
va:272) ~[HelloJava-1.0.jar:na]
        at org.springframework.context.support.PostProcessorRegistrationDelegate
.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:92) ~[He
lloJava-1.0.jar:na]
        at org.springframework.context.support.AbstractApplicationContext.invoke
BeanFactoryPostProcessors(AbstractApplicationContext.java:687) ~[HelloJava-1.0.j
ar:na]
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:525) ~[HelloJava-1.0.jar:na]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationConte
xt.refresh(EmbeddedWebApplicationContext.java:122) ~[HelloJava-1.0.jar:na]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.
java:693) [HelloJava-1.0.jar:na]
        at org.springframework.boot.SpringApplication.refreshContext(SpringAppli
cation.java:360) [HelloJava-1.0.jar:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java
:303) [HelloJava-1.0.jar:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java
:1118) [HelloJava-1.0.jar:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java
:1107) [HelloJava-1.0.jar:na]
        at maven.Test.main(Test.java:21) [HelloJava-1.0.jar:na]
Caused by: java.lang.IllegalArgumentException: No auto configuration classes fou
nd 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) ~[HelloJava
-1.0.jar:na]
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelecto
r.getCandidateConfigurations(AutoConfigurationImportSelector.java:153) ~[HelloJa
va-1.0.jar:na]
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelecto
r.selectImports(AutoConfigurationImportSelector.java:95) ~[HelloJava-1.0.jar:na]

        at org.springframework.context.annotation.ConfigurationClassParser.proce
ssDeferredImportSelectors(ConfigurationClassParser.java:547) ~[HelloJava-1.0.jar
:na]
        ... 14 common frames omitted

这个异常的解决方案是因为没有指定程序入口。

我们需要在POM里加入

<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>1.2.1</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
						<configuration>
							<transformers>
								<transformer
									implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
									<mainClass>maven.Test</mainClass>
								</transformer>
							</transformers>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>


条评论

请先 登录 后评论
不写代码的码农
三叔

421 篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除