admin管理员组文章数量:1642466
1.Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/util/unit/DataSize
启动时报错,问题是这个类在哪里用到都没找到,百度这个类发现它是springboot2.1的新特性,然后看了一下父工程的pom文件,发现自己粘贴的版本是1.4X,修改后项目就可以正常启动了
2.Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
springboot2.1引用的数据库驱动类是 com.mysql.cj.jdbc.Driver,修改自己的yml配置文件就不会有这个问题了
3.java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)
这个一看就知道是数据库连接失败,显示密码错误,但是自己明明写了正确的用户名和密码,看自己的配置文件发现配置参数名称有问题,依图修改后问题就解决了
4.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
看着这么多错误信息,其实正真的错误原因是下面这个causeby:
org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
这个英文意思就是没有设置hibernate的方言,我还是有个疑问,之前spring boot整合jpa没有设置方言,却并未发现此错误,解决问题就是在配置文件里面添加
database-platform: org.hibernate.dialect.MySQL5Dialect
5.项目启动完后自动停止了,自动创建表也完成了
2018-11-27 09:47:32.028 INFO 6140 --- [ main] c.w.p.ProviderUserApplication : Started ProviderUserApplication in 5.755 seconds (JVM running for 6.983)
2018-11-27 09:47:32.035 INFO 6140 --- [ Thread-12] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2018-11-27 09:47:32.040 INFO 6140 --- [ Thread-12] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2018-11-27 09:47:32.045 INFO 6140 --- [ Thread-12] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
修改:
修改完成后项目就可以正常启动访问了
6.This application has no explicit mapping for /error, so you are seeing this as a fallback.
消费服务调用提供者服务:报这个错,表示跳转的路径找不到
首先在配置文件配置路径
然后在controller层里面引入这个路径
7.创建springboot项目,自动生成的配置文件没有绿叶子图标
修改成yml文件后,写配置也没有自动提示,原因是项目没有spring的支持
解决方式:打开project structure,选择当前的模块,点击上面的+,选择spring添加进去
添加后,点击apply后图标就正常了
8.The bean 'dataSource', defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class] and overriding is disabled.
在启动类上添加注解
但是又有新的报错,找不到repository,添加@repository("userRepository"),@Qualifier("userRepository"),但是第一次运行是好的,添加了eureka后就不行了
clean项目后报错:
本文标签: 入门错误常见SpringCloud
版权声明:本文标题:springCloud入门的常见错误 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1729340219a1197446.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论