創建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選項,也可以勾選上,可以幫助我們自動去除不需要的導入類


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM