Maven打包,无法将application.properties配置打包

Maven打包,无法将application.properties配置打包

异常提示:
2022-02-12 04:55:04.912  WARN 6796 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productCategoryController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productCategoryServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productCategoryMapper' defined in file [D:\user\key\diancan\target\classes\com\wangheng\diancan\mapper\ProductCategoryMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2022-02-12 04:55:04.914  INFO 6796 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-02-12 04:55:04.926  INFO 6796 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-12 04:55:04.930 ERROR 6796 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

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).


Process finished with exit code 0

出现以上问题就是,maven打包过程中,没有将application.propreties打包,必须再,pom.xml中配置,打包时将配置文件打包的代码,即可

配置之前:运行Maven—》clean—》-----》pakage 之后再target目录下却没有,application.properties文件

在这里插入图片描述
需要在,maven的pom.xml文件中添加以下代码即可

    <build>
        <resources>
            <!--  配置将properties文件打印进去          -->
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                //配置maven打包时,扫描以什么结尾的文件,加载到打包过程中
                    <include>**/*.properties</include>
                </includes>
            </resource>
        </resources>
    </build>

**配置之后:**运行Maven—》clean—》-----》pakage,发现配置文件就存在了。
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在新建的maven项目中,如果没有看到application.properties配置文件,可以进行以下几个步骤来解决问题。首先,确保你的pom.xml文件中已经引入了springboot的依赖。接着,打开File菜单,选择Project Structure,然后在对应的模块中右键点击"Add",选择Spring和Web功能进行添加。再次确认一下resources文件夹是否已经被添加为Resources类型,可以在右侧的面板中查看是否已经添加成功。如果仍然没有解决问题,可能是因为maven引入的依赖没有被正确打包编译。此时,可以删除项目中的.iml文件,并在IDEA的maven面板中重新import项目,重新生成.iml文件。等待一段时间,.iml文件重新生成后,配置文件中的依赖包属性就可以正常提示了。通过以上步骤,你应该能够解决maven项目中缺失application.properties的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Spring boot中没有application.properties的解决方式](https://blog.csdn.net/libra_ts/article/details/78866419)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [springboot 基础简易实例, maven项目](https://download.csdn.net/download/kingwin28/11229434)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [Maven模块中application.properties配置文件没有高亮显示以及缺少部分提示](https://blog.csdn.net/mrzhuangwy/article/details/108039933)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值