Java Spring boot postgresql安装配置失败

Java Spring boot postgresql安装配置失败,java,spring,hibernate,spring-boot,jpa,Java,Spring,Hibernate,Spring Boot,Jpa,我正在尝试将spring boot应用程序连接到Postgres数据库, 但我无法设置,我也遵循spring入门教程和bealdum,但我无法解决问题: 这是我的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"

我正在尝试将spring boot应用程序连接到Postgres数据库, 但我无法设置,我也遵循spring入门教程和bealdum,但我无法解决问题:

这是我的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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>example</name>

    <properties>
        <java.version>11</java.version>
    </properties>

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

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </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-web</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
我的spring boot应用程序类:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@SpringBootApplication
@EnableJpaRepositories
public class ExampleApplication {

    public static void main(String[] args) {
        SpringApplication.run(ExampleApplication.class, args);
    }

}
控制器类:

import com.example.example.entities.Thing;
import com.example.example.repositories.ThingRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CreateThingController {

    private ThingRepository thingRepository;

    @Autowired
    public CreateThingController(ThingRepository thingRepository){
        this.thingRepository = thingRepository;
    }

    @PostMapping("/things")
    public void createThing(@RequestBody Thing thing) {
        this.thingRepository.save(thing);
    }
}
我的实体类:

import org.springframework.data.annotation.Id;

import javax.persistence.*;

@Entity
public class Thing {

    @Id
    @Column(name = "id", nullable = false, updatable = false)
    private String id;

    @Column(name = "name", nullable = false, updatable = false)
    private String name;

    public Thing(
            String id,
            String name
    ) {
        this.id = id;
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }
}
这是我的存储库界面:

import com.example.example.entities.Thing;
import org.springframework.stereotype.Repository;
import org.springframework.data.jpa.repository.JpaRepository;


@Repository
public interface ThingRepository extends JpaRepository<Thing, String> 
{

}
我试图在其他响应和教程之后修复错误,但失败了。
这里有什么问题?我需要配置其他内容?

您的对象类文件名是什么?像这样更改文件名并重新启动程序。

您拥有所有依赖项,但在启动过程中明确删除了数据库自动配置:

spring.autoconfigure.exclude=
      org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
注释或删除该属性

Parameter 0 of constructor in com.example.example.controllers.CreateThingController required a bean named 'entityManagerFactory' that could not be found.
spring.autoconfigure.exclude=
      org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration