java springboot 项目中遇到的问题
1. java.lang.IllegalArgumentException: Parameter Maps collection does not contain value for java.lang.Integer
参考: https://blog..net/u013042707/article/details/79950752
解决办法:mapper.xml 中IDE提示有parameterMap属性而这个属性已经早废弃了且应该使用parameterType,如果不小心写成parameterMap那就中招了!
2. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is 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.] with root cause
解决方法:修改application.yml中添加时区
spring:
datasource:
url: jdbc:mysql://localhost:3306/mysql_java01?serverTimezone=UTC
3. postman post方法发送(适用自己的项目,其他小伙伴不需要参考呢)
4. 创建spring boot项目时经常出现连接failed
在构建 SpringBoot 项目时,因为之前一直是用的默认地址
可以使用国内的网站进行替代,如:
5. mysql 启动问题
D:ProgrammerJavaCollectionMySql5_7in>mysqld --install Service successfully installed.
D:ProgrammerJavaCollectionMySql5_7in>net start mysql MySQL 服务正在启动 . MySQL 服务已经启动成功。
D:ProgrammerJavaCollectionMySql5_7in>mysql -uroot -p Enter password:
6. Field studentMapper in com.example.demo1.StudentService required a bean of type com.example.demo1.mapper.StudentMapper that could not be found.
很明显mapper没有加入ioc容器中,service处使用@Autowired拿的时候拿不到,需要使用
@MapperScan("com.example.demo1.mapper")扫描
7. 解决windows下Error:node with name "rabbit" already running on “XXX” 和管理页面打不开问题
安装erl 和 rabittMQ 后 发现rabbit的控制台页面无法打开,启动rabbit,抛如下异常:Error:node with name "rabbit" already running on “XXX”
这个是因为rabbit已经启动了,不能再次启动,通过tasklist指令,发现进程是存在的:tasklist | find /i "erl"
C:Userswangq>tasklist | find /i "erl" erlsrv.exe 7920 Services 0 3,376 K erl.exe 12828 Services 0 102,272 K
看到有结果,那么说明已经启动了,通过任务管理器kill掉进程再次启动即可
然后再运行 rabbitmq-server.bat 启动即可
ps:还有的情况下重启插件也可以解决,命令如下: rabbitmq-plugins enable rabbitmq_management
然后打开浏览器就可以看到控制台
8. 编写kafka consumer时,如果自己应答 ack.acknowledge() 则需要添加ack-mode的配置,不然会报错
Caused by: java.lang.IllegalStateException: No Acknowledgment available as an argument, the listener container must have a MANUAL AckMode to populate the Acknowledgment.
ack-mode配置:
spring.kafka.consumer.enableAutoCommit=false
spring.kafka.listener.ack-mode=manual
