我需要在TestConfiguration
中使用服务器数据库。我在我的application.properties
中定义了一个Postgresql数据库,应该由应用程序使用,但TestContext
使用的是嵌入式h2数据库。
application.properties
具有以下内容:
H2被定义为pom.xml file
中的依赖项,当我删除并尝试构建时没有出现错误:
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:180)
at org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
我做错了什么?
答案 0 :(得分:1)
问题是我在postgresql的pom中定义的范围。
['ASK', 'NOT', 'WHAT', ...]
当我将范围设置为提供一切正常时。