重新配置一次springboot我的pom里边的配置如下
百度了一下,说是少了thymeleaf包
在次运行,看看接下来还会不会出什么差错
哦发现刚刚还有一个人说,还要加一个config配置,于是,我又去加了一个config
结果一样,还是报了上面的500的错误
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn</groupId>
<artifactId>myfamilyt</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<!--war/jar-->
<name>myfamilyt</name>
<description>Demo project for Spring Boot</description>
<!--parent一般来说,一些公司有自己的parent,项目可以必须要使用公司的parent-->
<!-- maven 不支持多个parent-->
<!--<parent>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-parent</artifactId>-->
<!--<version>1.5.7.RELEASE</version>-->
<!--<relativePath/> <!– lookup parent from repository –>-->
<!--</parent>-->
<!--springboot进行统一版本的管理 两种方式,parent,dependencyManagement-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.7.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!--<exclusions><!–排除tomcat–>-->
<!--<exclusion>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
</dependency>
<!--tomcat所需 -->
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-data-jpa</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>javax.servlet</groupId>-->
<!--<artifactId>javax.servlet-api</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.7.RELEASE</version>
<configuration>
<mainClass>cn.myfamilyt.MyfamilytApplication</mainClass>
<classifier>exec</classifier>
</configuration>
</plugin>
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-war-plugin</artifactId>-->
<!--<configuration>-->
<!--<failOnMissingWebXml>false</failOnMissingWebXml>-->
<!--</configuration>-->
<!--</plugin>-->
</plugins>
</build>
</project>
其它写法都是正常的
但是报错了
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中加入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
在次运行,看看接下来还会不会出什么差错
很好继续报错
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数据库