Waitme9 2022-07-09 13:46 采纳率: 79.4%
浏览 99
已结题

关于spring maven项目properties配置文件不能被编译导致的错误

关于spring maven项目properties配置文件不能被编译导致的错误
一开始的错误如下:

Description:

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

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

试了网上的各种方法:加上@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})这个注解,虽然可以解决,但是到后面会报错,后来我发现是我的配置文件properties配置文件没有被编译,故而没有url这些数据,需要把
其中的

<packaging>pom</packaging>

去掉,但是我去掉会报错,又改为其他的jar,war等也会报错,如下:

img


pom里也可以需要的文件也打包,我是使用如下代码:

img


但是发现依旧不能打包,请问我该怎么办才能让我的配置文件properties被打包?

  • 写回答

2条回答 默认 最新

  • 江湖是人情世故 2022-07-11 07:17
    关注

    mybatis的版本修改一下,版本冲突导致的。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

问题事件

  • 系统已结题 7月19日
  • 已采纳回答 7月12日
  • 创建了问题 7月9日