错误

635 阅读2分钟

1.javac不能执行的错误

  • 环境变量没有配置好
  • windows10配置环境变量path里面不用加%JAVA_Home%,使用绝对路径

2.@Data注解使用后get set报错解决方法

  • 使用idea导入项目后,报错没有对应的get/set方法,但是项目上有@Data注解,pom文件也引入了相应的jar包,依然提示要生产get/set方法
  • 解决:因为新装的idea没有Lombok插件,因为Data是lombok包下的,所以要装Lombok插件,重新启动就好了

3.数据库连接:java.sql.SQLException: No suitable driver

  • 找不到合适的驱动
    折腾了半个小时后发现还是自己不仔细造成的

4.yml文件编写格式

  • 项目启动后报错,无法引入yml资源
    最后检查是书写格式不对造成的,要注意:
  • 1.缩进采用的是空格,不是tab键
  • 2.:之后必须跟空格,否则会报错

5.springboot使用@Cacheable注解缓存报错

java.net.ConnectException: Connection refused: no further information
	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_211]
	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_211]
	at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
	at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:670) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:617) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:534) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906) ~[netty-common-4.1.36.Final.jar:4.1.36.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.36.Final.jar:4.1.36.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.36.Final.jar:4.1.36.Final]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_211]

还没有找到解决方法

6.mysql时区设置

com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: 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.

命令: set global time_zone='+8:00';

7.Spring Security 无法登陆,报错:There is no PasswordEncoder mapped for the id “null”

  • 这是因为Spring security 5.0中新增了多种加密方式,也改变了密码的格式。

修改后的

protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        //inMemoryAuthentication 从内存中获取  
        auth.inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder()).withUser("user1").password(new BCryptPasswordEncoder().encode("123456")).roles("USER");
}
@Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        //super.configure(auth);
        auth.inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder())
                .withUser("zhangsan").password(new BCryptPasswordEncoder().encode("123456")).roles("VIP1","VIP2")
                .and()
                .withUser("lisi").password(new BCryptPasswordEncoder().encode("123456")).roles("VIP1","VIP3")
                .and()
                .withUser("wangwu").password(new BCryptPasswordEncoder().encode("123456")).roles("VIP2","VIP3");
    }

8.在测试类中测试连接mysql查询数据,报下面的错误

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'.
Could not create connection to database server. Attempted reconnect 3 times. Giving up.

连接不到服务器,提示更换mysql驱动,后来检查发现不是驱动的问题