创建spring boot项目启动报错遇到的问题

 

1、Spring boot,Mybatis 启动报错 Failed to auto-configure a DataSource

 

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

 

  解决方法:

  注解这样写:@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})

2、非法反射,报错信息

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/%e5%85%b3%e6%96%87%e5%b3%b0/.m2/repository/org/springframework/spring-core/5.0.6.RELEASE/spring-core-5.0.6.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

  警告信息,暂时没影响

3、idea运行springBoot项目报错 Process finished with exit code 0

  Deleting provided scope of spring-boot-starter-tomcat dependency helps me.

  在pom.xml中添加,然后导入

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>

4、alt + enter 导入类

  在使用idea开发java项目的时候,经常需要导入jdk或者是第三方类库的类,如果是自己手工导入的话,非常麻烦,效率很低,下面来介绍下如何设置idea,就可以实现自动导入

  设置自动导入的方式,来自动批量导入,打开idea的settings设置对话框

  在左上角的输入框中输入auto import关键字搜索,找到Editor>General>Auto Import

  勾选上add unambiguous imports on the fly选项,点击确认,关闭对话框

  在设置自动导入的窗口,还有一个Optimize imports on the fly选项,也可以勾选上,可以帮助我们自动去除不需要的导入类

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Spring Boot启动不了可能是由于以下几个原因导致的。首先,可能是远程下载Maven环境失败导致的。您可以尝试勾选启动项目或者不勾选启动项目来解决这个问题。 其次,您可以检查启动类的配置,重新添加Main Class,并确保正确选择了本地使用的JDK。如果没有正确选择JDK,可能无法选中启动类。最后,可能是Maven加载包有问题或者Maven本身加载出现了一些错误。您可以检查Maven的配置,确保项目依赖正确加载。如果在Maven创建项目或编译时出现错误,可能是由于Maven本身出现了问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [springboot 常见项目启动不了或启动报错的解决办法](https://blog.csdn.net/qq_44818449/article/details/125945609)[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_2"}}] [.reference_item style="max-width: 50%"] - *2* [SpringBoot项目遇到项目无法启动问题以及解决方法](https://blog.csdn.net/m0_49527007/article/details/122529734)[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_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值