如果我从InteliJ运行她,我的SpringBoot应用程序运行良好,但是当我尝试以.jar的身份从控制台打开时,我得到了:

java.lang.IllegalArgumentException:在META-INF / spring.factories中找不到自动配置类。

我在Stack上仅发现了一个与此相关的主题,对我没有帮助click

这是我的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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.location</groupId>
    <artifactId>mysql-rest-service</artifactId>
    <version>1.0-SNAPSHOTwithIP</version>


    <!-- Define the parent pom -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.8.RELEASE</version>
    </parent>

    <!-- Set the Java version -->
    <properties>
        <java.version>1.8</java.version>
        <start-class>com.location.restservice.Application</start-class>
    </properties>


    <packaging>jar</packaging>

    <dependencies>
        <!-- Spring Boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- JPA Data -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <!-- Data REST -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>

        <!-- MySQL Connector-J -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

    </dependencies>


    <!-- Spring Boot Maven Plugin -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>

                    <mainClass>${start-class}</mainClass>
                </configuration>

            </plugin>
        </plugins>
    </build>
</project>


有什么问题吗?我该怎么办?如果您有问题,请在评论中提问。

我在主班有@SpringBootApplication

最佳答案

尝试执行此mvn spring-boot:run

08-06 05:32