spring-boot创建项目遇到配置问题

来源:互联网 发布:mac os 10.13iso镜像 编辑:程序博客网 时间:2024/06/05 02:38

今天在创建spring-boot时遇到一个读取不到application.properties的问题,正常是将此文件放在src/main/resouces的子目录下,但是有时候为了方便管理所以需要将位置转移。 如下图所示:

此图中我是将文件放在src/main/resouces的propertiesConfig目录下,所以直接运行项目会找不到该文件,此时会报以下错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.

所以需要修改sping运行时读取的地址:@PropertySource("classpath:propertiesConfig/Application.properties")加上此注解就可以。此注解是加载application上的


对了,不知道为啥要在application这个类上加上@EnableAutoConfiguration这个注解


阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 女人便血是什么原因 拉肚子带血怎么回事 便血肛门疼 辣椒吃多了会便血吗 男生便血怎么回事 拉稀出血怎么回事 便血如何调理 屁股眼流血是怎么回事 肛门出血是什么原因引起的 肛门流鲜血 大便便血原因 便血肚子疼 肛门口出血 拉屎有血丝 连续便血 便鲜血不疼是怎么回事 大便带血的原因 便血是怎么了 大便暗红色 屁股擦出血 屁屁流血怎么回事 擦屁股有血迹 上大厕出血 男性大便出血 分泌物带血丝 便血是什么症状 肛门经常出血 肛门大量出血 擦屁股擦出血 长期便血 腹胀便血 肛门坠胀是怎么回事 便秘肛门出血 肛门痛出血 男人便血怎么回事 男士大便出血 屁股疼 连续几天便血怎么回事 肚子疼便血的原因有哪些 肛门 出血 上大厕出血怎么回事