我正在尝试使用Spring Boot CLI(1.5.7)实现一个使用h2数据库的小型REST服务 . 但解决依赖关系不起作用 . 我收到错误:“引起:org.springframework.beans.factory.UnsatisfiedDependencyException”...“工厂方法'dataSource'抛出异常;嵌套异常是org.springframework.boot.autoconfigure.jdbc.DataSourceProperties $ DataSourceBeanCreationException:无法确定数据库类型为NONE的嵌入式数据库驱动程序类“
@Grab("h2")
import java.sql.ResultSet
class ContactRepository {
@Autowired
JdbcTemplate jdbc
List<Contact> findAll() { ... }
}
我想通过使用@Grab(“h2”)Spring Boot会将类/ jar添加到类路径中 . 我无法找到有关Spring Boot CLI(不是 Cloud 版本)的更多信息 . 我会非常感谢你的帮助 .
2 回答
加
在你的pom中,模块和spring boot会自动检测类路径上的hsqldb .
不确定,但也许你的类必须被标记为Spring托管类,即将
@Repository
或@Component
(无关紧要)添加到ContactRepository
类 .