Spring启动:获取错误“;无法为数据库类型NONE确定嵌入式数据库驱动程序类“;从eclipse运行JUnit测试时

Spring启动:获取错误“;无法为数据库类型NONE确定嵌入式数据库驱动程序类“;从eclipse运行JUnit测试时,junit,spring-boot,Junit,Spring Boot,在一个简单的Spring引导应用程序上直接从Eclipse运行JUnit测试(在我想要运行的JUnit测试文件上使用“RunAs JUnit test”)有点问题 我使用Gradle作为构建工具。现在,当作为Gradle任务运行测试时,它工作得很好,但是当作为eclipsejunit任务运行时,它失败了,出现以下错误 java.lang.IllegalStateException: Failed to load ApplicationContext ... Caused by: org.spri

在一个简单的Spring引导应用程序上直接从Eclipse运行JUnit测试(在我想要运行的JUnit测试文件上使用“RunAs JUnit test”)有点问题

我使用Gradle作为构建工具。现在,当作为Gradle任务运行测试时,它工作得很好,但是当作为eclipsejunit任务运行时,它失败了,出现以下错误

java.lang.IllegalStateException: Failed to load ApplicationContext
...
Caused by: org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.
My application.properties文件确实定义了一个本地MySQL数据库,它似乎可以与gradle配合使用:

spring.datasource.url: jdbc:mysql://localhost:3306/test
spring.datasource.username=user
spring.datasource.password=pass
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
我的申请类别:

@SpringBootApplication
public class Application {
我的应用程序测试:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
public class ApplicationTests {

有什么想法吗?

您注意到了吗,对于spring.datasource.url,您放了:而不是=?如果无法获取URL,它将尝试创建嵌入式数据库。我刚发现问题出在哪里。我禁用了eclipse构建。当我使用EclipseBuilder(而不是使用gradle)构建项目时,EclipseJUnit运行程序开始工作,我的测试通过了?如果无法获取URL,它将尝试创建嵌入式数据库。我刚发现问题出在哪里。我禁用了eclipse构建。当我使用EclipseBuilder(而不是使用gradle)构建项目时,EclipseJUnit运行程序开始工作,我的测试通过了。