我試圖在Spring Boot中使用非嵌入式PostgreSQL數據庫。但是,當我嘗試運行我的應用程序「MVN春天啓動:運行」時,應用程序無法啓動並顯示以下消息:非嵌入式Postgresql在春季啓動
無法確定數據庫類型無嵌入式數據庫驅動程序類
這些都是我的從pom.xml的依賴關係:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency>
<dependency>
<!-- Eureka service registration -->
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<!-- Spring Cloud starter -->
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-jwt</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1206-jdbc42</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.pew.common</groupId>
<artifactId>backend-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>spring-mock-mvc</artifactId>
<version>3.0.2</version>
<scope>test</scope>
</dependency>
</dependencies>
這是我在application.yml設置:
spring:
profiles: dev
application:
name: resource-service
jpa:
database: POSTGRESQL
datasource:
platform: postgres
url: jdbc:postgresql://${postgresqlHost:localhost}:${postgresqlPort:5432}
username: ${postgresqlUsername:root}
password: ${postgresqlPassword:SomePassword}
driverClassName: org.postgresql.Driver
我無法找到這個這讓我覺得,這可能是一些真正容易得到工作太多的信息...
datasource屬性應該直接在spring下,而不是在spring.jpa下。所有你需要的是網址,用戶名和密碼。 –