启动springboot的时候报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'druidDataSourceConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}"
查了n久之后发现是application.yml文件没有在target/classes下生成。
target/classes 目录是IDEA的classpath目录,项目编译后配置文件必须在这个目录下才可以访问到,手动将配置文件拷贝到target/classes目录下面,问题解决!
那么怎么生成呢?
只需要在pom文件中加入
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.xls</exclude>
<exclude>**/*.xlsx</exclude>
</excludes>
</resource>
</resources>
因为我的项目里有excel文件所以把它过滤了
运行后ok