2015-05-25 26 views
1

我越來越想在Eclipse中運行(運行方式> Java應用程序)的應用程序時,這個錯誤:錯誤春季創建數據源的Postgres引導

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. 
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassN ame(DataSourceProperties.java:137) 
at org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:117) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
at java.lang.reflect.Method.invoke(Unknown Source) 
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) 
... 169 more 

但是,當我在命令窗口中運行(MVN春天-boot:運行)它運行完美。

Application.properties:

spring.jpa.database=POSTGRESQL 
spring.datasource.platform=postgres 
spring.jpa.show-sql=true 
spring.jpa.hibernate.ddl-auto=create-drop 
spring.database.driver-class-name=org.postgresql.Driver 
spring.datasource.url=jdbc:postgresql://localhost:5432/gafanhotator 
spring.datasource.username=postgres 
spring.datasource.password=postgres 
spring.thymeleaf.cache=false 

的pom.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>br.com.gafanhotator</groupId> 
    <artifactId>gafanhotator-dev</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>gafanhotator</name> 
    <description>Gafanhotator Spring Boot Project</description> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.2.3.RELEASE</version> 
     <relativePath /> <!-- lookup parent from repository --> 
    </parent> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <start-class>br.com.gafanhotator.GafanhotatorApplication</start-class> 
     <java.version>1.8</java.version> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-actuator</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-aop</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-data-jpa</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-jdbc</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-security</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-social-facebook</artifactId> 
     </dependency> 

     <!-- Web Dependecy --> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 

     <!-- Thymeleaf Dependecy --> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-thymeleaf</artifactId> 
     </dependency> 

     <!-- Postgres --> 

     <dependency> 
      <groupId>org.postgresql</groupId> 
      <artifactId>postgresql</artifactId> 
      <version>9.4-1201-jdbc41</version> 
     </dependency> 

     <!-- Guava Dependecy --> 

     <dependency> 
      <groupId>com.google.guava</groupId> 
      <artifactId>guava</artifactId> 
      <version>18.0</version> 
     </dependency> 

     <!-- Test Dependecy --> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
      <scope>test</scope> 
     </dependency> 

    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
       <dependencies> 
        <dependency> 
         <groupId>org.springframework</groupId> 
         <artifactId>springloaded</artifactId> 
         <version>1.2.0.RELEASE</version> 
        </dependency> 
       </dependencies> 
      </plugin> 
     </plugins> 
    </build> 

</project> 

這是非常奇怪的,我已經在STS嘗試過,同樣的錯誤。有任何想法嗎?

回答

1

我不知道如何以及爲什麼,但是在Source「src/main/resources」的Java Build Path中,它被設置爲排除所有* .java,* .yaml和* .properties文件。我只是排除這些模式,一切都很成功。

這是一個eclipse的默認設置嗎?