SpringBoot项目启动异常 :no profiles are currently active

本地的SpringBoot项目平时起都没问题,想验证个功能点的时候突然起不来,报这个错误


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

看了下不是因为数据库连接的问题,再看profile也激活了,

SpringBoot项目启动异常 :no profiles are currently active_第1张图片

试了各种方式都不行,然后百思不得其解。苦思冥想中试了下不经过编译直接运行,发现竟然好使了,灵机一动看下编译出来的target文件。

经过mvn命令:

SpringBoot项目启动异常 :no profiles are currently active_第2张图片

不经过mvn命令直接启动:

SpringBoot项目启动异常 :no profiles are currently active_第3张图片

从上面图中可以看出问题了,经过mvn命令的缺少了配置文件,所以运行不起来,

解决办法是:


    
        
            org.springframework.boot
            spring-boot-maven-plugin
        
    
    
        
            src/main/java
            
                **/*.xml
            
        
    ----------------------指定将resources中配置文件加载到target-----------------------
        
            src/main/resources
            
                **/*.properties
            
        
 --------------------------指定将resources中配置文件加载到target-------------------
    

希望能帮助到遇到同样问题的你(#^.^#)~。

 

你可能感兴趣的:(#,SpringBoot)