spring boot项目部署Linux时tomcat启动失败,打war包后不存在resources下的资源文件

spring boot项目部署Linux时,运行tomcat启动报错

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

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-09 20:32:20.318 ERROR 23315 --- [ost-startStop-1] 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

查看linux服务器中/webapps/ROOT/WEB-INF/classes下的项目文件,发现不存在application.properties文件

设置由于pom文件里面配置< resources >时未设置打包.properties文件,导致tomcat读取不到.properties文件的配置信息。

在< resources >中加入扫描.properties文件即可 注意往下看

<resource>
    <directory>src/main/resources</directory>
    <includes>
        <include>**/*.properties</include>
    </includes>
</resource>

如果只配置.properties文件可能会导致进入tomcat运行成功后访问项目静态资源文件报错。

异常:
This application has no explicit mapping for /error, so you are seeing this as a fallback.

javax.servlet.ServletException: Circular view path [login]: would dispatch back to the current handler URL [/login] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
在这里插入图片描述

此时需要设置扫描src/main/resources下的全部文件

<build>

        <finalName>jfkj-crm</finalName>

        <!--解决在src/main/java下不能读取xml的问题-->
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            
            <!--扫描src/main/resources下的全部文件-->
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.*</include>
                </includes>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

欢迎访问本文的个人博客链接: https://br-bai.github.io/2019/06/10/SpringBoot项目部署Linux时Tomcat启动失败,打war包后不存在resources下的资源文件/

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值