springboot出现SpringApplication无法导入包的问题

最简单的springboot入门配置,出现SpringApplication无法import包,maven下载jar失败

推荐方法三,可以先试试方法三

springboot出现SpringApplication无法导入包的问题_第1张图片

点开SpringApplication错误

springboot出现SpringApplication无法导入包的问题_第2张图片

1.

找到C:\Users\lenovo\.m2\repository\org\springframework\boot下面的spring-boot-autoconfigure,把他删除

项目右键—>Run As—>Maven clean

然后项目右键—>Maven—>Update Project..

项目右键—>Run As—>Maven install

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project springboot: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]

这是提示jdk环境不对

2.

springboot出现SpringApplication无法导入包的问题_第3张图片

配置jdk路径

springboot出现SpringApplication无法导入包的问题_第4张图片

选择jdk路径

springboot出现SpringApplication无法导入包的问题_第5张图片

选择jdk文件夹下的jre,并且是选到这个文件,而不是选择同级的jre

3.

更改pom文件,我的jdk是1.8的,所以这里指定跟本地一样的1.8版本

这里1.5.7.RELEASE的springboot是官方推荐的文件版本的


    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    4.0.0
    com.ma.springboot
    springboot
    0.0.1-SNAPSHOT
    jar

    springboot
    http://maven.apache.org
    
        UTF-8
        1.8
    
    
    org.springframework.boot
    spring-boot-starter-parent
    1.5.7.RELEASE


    
        org.springframework.boot
        spring-boot-starter-web
    


    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

最后导入junit包,apptest错误也消失

项目右键—>Run As—>Maven clean

然后项目右键—>Maven—>Update Project..

项目右键—>Run As—>Maven install

你可能感兴趣的:(spring,boot)