学无先后,达者为师

网站首页 编程语言 正文

SpringBoot 项目启动报错 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded

作者:NGU7180 更新时间: 2024-03-08 编程语言

在初始化springboot项目的时候,启动一个test测试的时候,成功遇到了这个错误,

当时我的application.yml配置是未被注释的这个.

然后我采取了以下步骤,

  1. 将上面报错的配置改为下面的
  2. 修改配置文件名称从application.yml到application.properties
  3. 根据一宿君的文章,在<build>标签下添加了<resources>标签,引入了该文件,注意一定要放在build标签下,否则会报错
    <!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.yml</include>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
            </includes>
            <filtering>false</filtering>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.yml</include>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
            </includes>
            <filtering>false</filtering>
        </resource>
    </resources>
    

    至此,测试成功运行通过,

原文链接:https://blog.csdn.net/NGU7180/article/details/136404394

  • 上一篇:没有了
  • 下一篇:没有了
栏目分类
最近更新