问题1:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
原因:项目初始化事,勾选了数据库,由于jdbc等没有配置,因此报错
解决:
在application.properties文件中配置数据库,如
spring.datasource.url=jdbc:mysql://localhost:3306/test?characterEncoding=utf-8 //配置url
spring.datasource.driver-class-name=com.mysql.jdbc.Driver //配置驱动器
spring.datasource.username=root //配置数据库用户名
spring.datasource.password=root //配置数据库密码
mybatis.mapper-locations=classpath:mapper/*.xml
//配置映射器位置为(src/main/resources/)mapper包下,所有以.xml结尾的文件,项目默认映射器位置为templates包
问题2:
java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone.
原因:数据库配置好后,可能会出现如上错误,可能原因是mysql的版本太高
解决:
在pom.xml文件中,将mysql的版本设置低一些,如
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version> //改变该处版本为5.1.47或其他
<scope>runtime</scope>
</dependency>
问题3:页面报错 whitelabel Error Page
原因:tomcat没有配置好
解决:
1、打开Edit Configurations
(1)Run-->Edit Configurations
(2)点击右上角Build Project按钮右边的下拉框,点击Edit Configurations
2、点击左上角+ -->点击Tomcat Server -->点击Local
3、填写Tomcat命名-->点击Deployment-->点击+-->点击Artifacts-->选择项目
4、配置好以上操作后,点击Apply,然后再刷新页面即可