首页 新闻 赞助 找找看

IDEA使用Spring initializr新建Spring Boot项目每次运行启动类都会报找不到程序包的错

0
悬赏园豆:30 [待解决问题]

大体情况如题,另详细内容如下:
JDK: 1.8
Maven:3.6.3
Win10系统,只有一个C盘
图片说明
图片说明<br>

代码及编译情况如图2所示,现在问题如下:
         相关jar已经通过Maven加载,代码无编译错误,使用IDEA的Maven插件install都是build success,但是运行DemoApplication的时候会提示Spring相关包找不到,相同的环境,我直接新建Maven项目,然后相同的pom配置,相同的代码,相同的操作,却是一切正常。
            另外,我每次重启IDEA之后,Maven的所有依赖全都会消失,需要重新reimport,这一点也想不通是为什么。
            代码参考[](https://spring.io/guides/gs/serving-web-content/ "")

另附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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </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>
    </dependencies>

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

</project>
渟峙的主页 渟峙 | 菜鸟二级 | 园豆:372
提问于:2020-02-25 21:06
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册