1、第一个坑,自动注入某个类失败
Field demoService in .......... required a bean of type '...........' that could not be found.
Consider defining a bean of type '..............' in your configuration.
原因:路径错误
解决办法:这属于项目结构的问题,项目启动时,只有@SpringBootApplication 所在的包被扫描。此启动类应处于最上层的目录中,这样项目启动时,该目录以及下级目录的类都会被扫描。
2、第二个坑,报nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [hibernate_sequence]这个错,如图:
错误原因及解决办法:
根据hibernate_sequence关键字终于查到了原因。
在使用@GeneratedValue注解时,需要添加策略配置,即@GeneratedValue(strategy = GenerationType.IDENTITY)
3、第三个坑@SpringApplicationConfiguration 这个注解不能用
原因及解决办法:@SpringApplicationConfiguration 注解在1.4就被替换了,新版本这个注解已经不能用了。
直接用注解@RunWith(SpringRunner.class) @SpringBootTest
持续更新中…………