【问题标题】:@SpringBootApplication Not found error coming on module@SpringBootApplication Not found 模块出现错误
【发布时间】:2021-11-02 14:43:16
【问题描述】:

我正在创建微服务应用程序。我们在项目中有一个pom。在此之下,我们有多个模块。我正在使用Java11spring 2.5.4.

下面是我的pom。从此所有modules 将获得版本。它的包装是pom

<?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>
    <modules>
        <module>twitter-to-kafka-service</module>
    </modules>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.microservices.demo</groupId>
    <artifactId>microservices-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>microservices-demo</name>
    <description>Microservices demo project for Spring Boot</description>
    <packaging>pom</packaging>

    <properties>
        <java.version>11</java.version>
        <spring-boot.version>2.5.4</spring-boot.version>
        <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
        <twitter4j.version>4.0.7</twitter4j.version>
        <lombok.version>1.18.16</lombok.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
                <version>${spring-boot.version}</version>
            </dependency>

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <version>${spring-boot.version}</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.junit.vintage</groupId>
                        <artifactId>junit-vintage-engine</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

            <!-- https://mvnrepository.com/artifact/org.twitter4j/twitter4j-stream -->
            <dependency>
                <groupId>org.twitter4j</groupId>
                <artifactId>twitter4j-stream</artifactId>
                <version>${twitter4j.version}</version>
            </dependency>

            <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok.version}</version>
                <scope>provided</scope>  <!-- only for compile time-->
            </dependency>


        </dependencies>

    </dependencyManagement>



    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>

    </build>

</project>

在这个项目下,我创建了一个模块,下面是 pom。

<?xml version="1.0" encoding="UTF-8"?>
<!--suppress MavenModelInspection, MavenModelInspection -->
<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">
    <parent>
        <artifactId>microservices-demo</artifactId>
        <groupId>com.microservices.demo</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>twitter-to-kafka-service</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.twitter4j</groupId>
            <artifactId>twitter4j-stream</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>  <!-- only for compile time-->
        </dependency>
    </dependencies>

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

    <properties>
        <maven.compiler.source>15</maven.compiler.source>
        <maven.compiler.target>15</maven.compiler.target>
    </properties>

</project>

现在我正在创建主类,我们的应用程序将从这里开始。 所以当我在做@SpringBootApplication 时,它说没有找到。我真的不确定我错过了什么。

我需要您的帮助来解决我刚刚启动并卡住的问题。请帮助我。

【问题讨论】:

    标签: java spring-boot maven microservices java-11


    【解决方案1】:

    您正在使用 IntelliJ IDEA 并且没有更新 pom 信息(右上角的图标带有小“m”符号。)

    因此无法正确解析依赖关系。

    此外,如果没有真正的要求,我建议对 Spring Boot 应用程序使用单个模块项目。

    【讨论】:

      猜你喜欢
      • 2017-09-03
      • 2011-05-06
      • 1970-01-01
      • 2013-09-20
      • 2018-07-19
      • 1970-01-01
      • 2022-08-19
      • 1970-01-01
      • 2017-11-25
      相关资源
      最近更新 更多