小编Atu*_*wal的帖子

未找到数据库“C:/data/sample”,并且 IFEXISTS=true,因此我们无法自动创建它 - Spring Boot 中的错误

我创建了一个 spring boot 应用程序来连接 h2 数据库。这样做时,它会引发错误,显示未找到数据库。请帮助我解决我可以实施和解决问题的解决方案。

我在 pom.xml 文件中添加了 com.h2database 依赖项,然后它也给出了错误。

下面是我的 pom.xml 文件和 application.properties 文件

pom.xml

<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.4.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
    <groupId>com.example</groupId>
    <artifactId>santanderdbproj</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>firstproject</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
    </properties>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <scope>runtime</scope>
</dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring …
Run Code Online (Sandbox Code Playgroud)

h2 pom.xml spring-boot microservices application.properties

3
推荐指数
3
解决办法
1万
查看次数