Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could

问题描述

Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.

解决

从报错上来看,是datasource没有配置好。

网上有很多解决方法,还遗漏了我下面这种情况:

在pom.xml中,yml文件被排除了:

            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                  <exclude>*.yml</exclude>
                    <exclude>*.xml</exclude>
                    <exclude>*.properties</exclude>
                </excludes>
            </resource>

这种情况,你是万万想不到的。都排除引用yml了,肯定datasource配置有问题。

解决方法就是注释排除,如下:

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- 跳过单元测试 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
<!--                <excludes>-->
<!--                  <exclude>*.yml</exclude>-->
<!--                    <exclude>*.xml</exclude>-->
<!--                    <exclude>*.properties</exclude>-->
<!--                </excludes>-->
            </resource>
        </resources>
    </build>
上一篇:1090 危险品装箱


下一篇:CONFIGURE命令--RMAN 配置参数说明