配置SpringBoot运行出现Error:o.s.b.d.LoggingFailureAnalysisReporter解决办法
初学SpringBoot,编写了一个简单的输出程序。//HelloControllerimport org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;/*@ResponseBody@Controller*/@Rest
·
初学SpringBoot,编写了一个简单的输出程序。
//HelloController
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/*@ResponseBody
@Controller*/
@RestController
public class HelloController {
@RequestMapping("/hello")
public String handle01(){
return "Hello,Spring Boot 2!";
}
}
//MainApplication
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MainApplication {
public static void main(String[] args) {
SpringApplication.run(MainApplication.class,args);
}
}
运行时,出现Error:o.s.b.d.LoggingFailureAnalysisReporter,无法在浏览器打开http://localhost:8080/hello网站,显示无法访问。
错误分析:
一、依赖:打开pom.xml
检查是否把springboot的依赖代码加进去,打开https://docs.spring.io/spring-boot/docs/current/reference/html/getting-started.html#getting-started.first-application.pomd
按步骤添加代码。
二、xml配置:在maven的conf目录下找到settrings.xml,打开写入代码
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compilerVersion>
</properties>
</profile>
</profiles>
尝试以上方法,仍无法正常运行程序。怀疑8080端口被占用。
在idea项目,resources目录下创建application.properties,输入
server.port=8989
将端口号替换为8989
再次运行,成功在http://localhost:8989/hello输出Hello,Spring Boot 2!
更多推荐
已为社区贡献1条内容
所有评论(0)