---
# System prepended metadata

title: Spring Boot 常見debug 大全
tags: [SpringBoot]

---

---
title: 'Spring Boot 常見debug 大全'
disqus: hackmd
---
###### tags: `SpringBoot`
Spring Boot 常見debug 大全
===

[TOC]

## 筆記目的



## 套件衝突

![](https://i.imgur.com/IC8Xd3t.png)


解決方法 可以考慮 將 pom.xml的一些版本號移除


## 沒有掃描檔案


解決方法:加上@ComponentScan



```java=
@EnableRetry
@SpringBootApplication
@PropertySource({"classpath:db-${spring.profiles.active}.properties"})
@ComponentScan(basePackages = {
		"com.allproduct.aicenter"
	}, 
		excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {})

	)

public class ApplicationModelCenterApplication implements ApplicationRunner {
	
	@Autowired
	private EmailService emailService;
	
	@Autowired
	private ApplicationProperties applicationProperties;
	
```

## 資料庫的問題

> org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]:

解法是因為有複數的資料庫，所以要加上configuration



## Target runtime Apache Tomcat v8.5 is not defined.

https://blog.csdn.net/Richard1997/article/details/80665799


