springboot报错(二) Internal Server Error,status=500

重新配置一次springboot我的pom里边的配置如下


	4.0.0

	cn
	myfamilyt
	0.0.1-SNAPSHOT
	jar
	

	myfamilyt
	Demo project for Spring Boot

	
	
		
		
		
		
	

	
	
		
			
				org.springframework.boot
				spring-boot-dependencies
				1.5.7.RELEASE
				pom
				import
			
		
	

	
		UTF-8
		UTF-8
		1.8
	

	

		
			org.springframework.boot
			spring-boot-starter
		

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

		
		
			
			
		

		
			
			
		

		
		
		
		
		

		
			org.springframework.boot
			spring-boot-starter-test
			test
		

		
			mysql
			mysql-connector-java
		


	

	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
				1.5.7.RELEASE
				
					cn.myfamilyt.MyfamilytApplication
					exec
				
			
			
				
				
				
					
				
			
		
	



 


其它写法都是正常的

但是报错了

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Wed Sep 20 10:51:19 CST 2017
There was an unexpected error (type=Not Found, status=404).
No message available

百度了一下,说是少了thymeleaf包

所以就在pom中加入

		
			org.springframework.boot
			spring-boot-starter-thymeleaf
		

在次运行,看看接下来还会不会出什么差错

很好继续报错

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Wed Sep 20 10:55:27 CST 2017
There was an unexpected error (type=Internal Server Error, status=500).
Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers

哦发现刚刚还有一个人说,还要加一个config配置,于是,我又去加了一个config

@Configuration
@EnableWebMvc
public class Config extends WebMvcConfigurerAdapter{
    @Override
    public void configureDefaultServletHandling(
            DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }
}

结果一样,还是报了上面的500的错误

哦,因为我比较懒,所以使用的是yaml格式的没使用properties (application.yaml)

最后想起,SpringBoot的一些配置需要进application里边配置,但是我第一次配置的是mvc的View这样就错了

spring:
  mvc:
    view:
      suffix: .ftl
      prefix: classpath:/templates/


因为使用了thymeleaf所以,使用mvc的自然是无用的,必须要修改为thymeleaf才行

spring:
  thymeleaf:
    prefix: classpath:/templates/
    suffix: .ftl

然后在重新运行了一次,果然成功了!问题成功解决

下就步配置mybatis数据库

springboot报错(二) Internal Server Error,status=500_第1张图片

你可能感兴趣的:(springboot)