1. 程式人生 > >SpringBoot2 初始資料庫迴圈依賴 The dependencies of some of the beans in the application context form a cycle

SpringBoot2 初始資料庫迴圈依賴 The dependencies of some of the beans in the application context form a cycle

今天做初始化資料庫,報一下異常

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

Description:

The dependencies of some of the beans in the application context form a cycle:

   userServiceImpl (field com.rude.springboot2.demo.dao.UserDao com.rude.springboot2.demo.service.impl.UserServiceImpl.userDao)       ↓    userDao defined in file [D:\Java\ideaIU\workspace\study\springboot2\demo\target\classes\com\rude\springboot2\demo\dao\UserDao.class] ┌─────┐ |  sqlManagerFactoryBean defined in class path resource [com/ibeetl/starter/BeetlSqlSingleConfig.class] ↑     ↓ |  beetlSqlDataSource defined in class path resource [com/ibeetl/starter/BeetlSqlSingleConfig.class] ↑     ↓ |  dataSource defined in class path resource [com/rude/springboot2/demo/config/BeetlSqlConfiguration.class] ↑     ↓ |  org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker └─────┘  

這就尷尬了,查了一天,還看了原始碼,一天沒吃飯了,中午查出來了。

解決方法,將程式碼下列程式碼新增    exclude = DataSourceAutoConfiguration.class

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

為:

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

問題解決,好了,不說了,簡單的記錄下,吃飯去了,都是淚啊!!!