搭建参考博文:https://www.jianshu.com/p/61d16f8ad23a
【SSM框架从零开始2】IntelliJ IDEA下Spring MVC数据库配置与增删改查开发
遇到的问题:解决Navicat for MySQL 连接 Mysql 8.0.11 出现1251- Client does not support authentication protocol 错误
解决方案:
https://blog.csdn.net/gsycwh/article/details/56675836#commentBox
遇到的问题:<!--找不到.DriverManagerDataSource-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
遇到的问题:<!--显示datasoursebean配置错误,无加载jdbc.drive--> 下载mysql的驱动程序 就是Maven 添加 JDBC 驱动
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
遇到的问题:
<!--找不到类型为:class java.util.ArrayList的返回值的转换器
json转换错误:No converter found for return value of type -->
<dependency><!--找不到类型为:class java.util.ArrayList的返回值的转换器 -->
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.5</version>
</dependency>
由于原本该的版本为2.7.4 所以与spring5.0.5不兼容 改为5..0.5中的版本即可,所以还是出现了最后一个问题
Servlet.init() for servlet [SpringMVC] threw exception 可参考https://mvnrepository.com/artifact/org.springframework/spring-webmvc/5.0.5.RELEASE
解决方案:https://blog.csdn.net/gsycwh/article/details/56675836
遇到的问题:
java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
因为mysql升级到8.0.13所以会出现没有统一时区的问题,java.sql.SQLException:服务器时区值'Öйú±ê׼ʱ¼ä'无法识别或代表多个时区。如果要使用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值。
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/test01?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</bean>
无法使用&符号,改为(&;)即可使用
解决方案:https://blog.csdn.net/gnail_oug/article/details/84653878
遇到的问题:
Type 异常报告
消息 Servlet.init() for servlet [SpringMVC] threw exception
描述 服务器遇到一个意外的情况,阻止它完成请求。
Servlet [SpringMVC]的Servlet.init()引发了异常
解决方案:
可能是不兼容吧 我也不知道为什么 可以参考,出现 HTTP Status 500 - Servlet.init() for servlet springmvc threw exception 异常的原因及解决方法https://blog.csdn.net/qq_35246620/article/details/54745098
因为由于原本该的版本为2.7.4 所以与spring5.0.5不兼容 改为5..0.5中的版本即可(就是2.9.5),
https://mvnrepository.com/artifact/org.springframework/spring-webmvc/5.0.5.RELEASE
一些小的问题,访问地址示例:http://localhost:8080/SpringMvc_war_exploded/(user/getAllUsers)->
@RequestMapping("user")@RequestMapping("getAllUsers")
包扫描读不到包 正确地址intellij idea报错 反正扫描包的相对地址是在classes下面的 classes和lib同一级,我也不知道是为啥