在meta inf/spring.factories中找不到自动配置类Spring Boot

neskvpey  于 2021-07-06  发布在  Java
关注(0)|答案(1)|浏览(535)
java -jar whereis.jar

执行spring boot项目的jar文件时出错:

.   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                        

2020-11-13 20:54:47.674  INFO 16398 --- [           main] io.shakhzod.whereis.WhereisApplication   : Starting WhereisApplication on shakhzod with PID 16398 (/home/shakhzod/Downloads/whereisbot/out/artifacts/whereis_jar/whereis.jar started by shakhzod in /home/shakhzod/Downloads/whereisbot/out/artifacts/whereis_jar)
2020-11-13 20:54:47.676  INFO 16398 --- [           main] io.shakhzod.whereis.WhereisApplication   : No active profile set, falling back to default profiles: default
2020-11-13 20:54:47.823 ERROR 16398 --- [           main] o.s.boot.SpringApplication               : Application run failed

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:470) ~[whereis.jar:na]
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:180) ~[whereis.jar:na]
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAutoConfigurationEntry(AutoConfigurationImportSelector.java:123) ~[whereis.jar:na]
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:434) ~[whereis.jar:na]
        at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:879) ~[whereis.jar:na]
        at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:809) ~[whereis.jar:na]
        at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:780) ~[whereis.jar:na]
        at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:193) ~[whereis.jar:na]
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:319) ~[whereis.jar:na]
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236) ~[whereis.jar:na]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280) ~[whereis.jar:na]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96) ~[whereis.jar:na]
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707) ~[whereis.jar:na]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533) ~[whereis.jar:na]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[whereis.jar:na]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[whereis.jar:na]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[whereis.jar:na]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405) ~[whereis.jar:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[whereis.jar:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[whereis.jar:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[whereis.jar:na]
        at io.shakhzod.whereis.WhereisApplication.main(WhereisApplication.java:16) ~[whereis.jar:na]

我的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">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>io.shakhzod</groupId>
    <artifactId>whereis</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>whereis</name>
    <description>telegram bot</description>

    <properties>
        <start-class>io.shakhzod.whereis.WhereisApplication</start-class>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.telegram</groupId>
            <artifactId>telegrambots-spring-boot-starter</artifactId>
            <version>4.9.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.2.9.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.5.2.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>resources</directory>
                <targetPath>${project.build.outputDirectory}</targetPath>
                <includes>
                    <include>application.properties</include>
                </includes>
            </resource>
        </resources>
    </build>

</project>

谁能帮忙?
我在stackoverflow中尝试了与我的问题相关的所有可能的答案,但没有结果,请帮助

8mmmxcuj

8mmmxcuj1#

你用的是Spring Boot 1.5.2.RELEASE 的maven插件和spring boot 2.3.5.RELEASE . 你应该总是使用相同的版本。当你使用 spring-boot-starter-parent 作为项目的父级,最简单的方法是从 <build> pom部分:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>1.5.2.RELEASE</version>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

这将允许父级控制所使用的maven插件的版本,从而确保两者保持同步。

相关问题