IT/development

[springBoot] springBoot ์‹คํ–‰ ์‹œ dataSource ์ œ์™ธ

์•Œ ์ˆ˜ ์—†๋Š” ์‚ฌ์šฉ์ž 2023. 10. 14.

springBoot ์‹คํ–‰ ์‹œ DB ์—ฐ๊ฒฐ์„ ๊ธฐ๋Œ€ํ•˜๋Š”๋ฐ DB์—ฐ๊ฒฐ์ด ํ•„์š”์—†๋Š” ๊ธฐ๋Šฅ์„ ๋งŒ๋“ค ๋•Œ๋Š” ์ด์กฐ์ฐจ๋„ ๊ท€์ฐฎ๋‹ค.

๊ทธ๋Ÿด ๋•Œ ์•„๋ž˜์ฒ˜๋Ÿผ ๋ฉ”์ธ ๋ฉ”์†Œ๋“œ์˜ @SpringBootApplication์— exclude ์˜ต์…˜์„ ์ฃผ๋ฉด ๋œ๋‹ค.

package study.springaoptest1;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class SpringAopTest1Application {

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

}
//์–ด๋…ธํ…Œ์ด์…˜ ์˜ต์…˜์— exclude๋ฅผ DataSource ํด๋ž˜์Šค ์ถ”๊ฐ€
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})

๊ฐœ์ธ ์Šคํ„ฐ๋”” ๊ธฐ๋ก์„ ๋ฉ”๋ชจํ•˜๋Š” ๊ณต๊ฐ„์ด๋ผ ํ‹€๋ฆฐ์ ์ด ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ‹€๋ฆฐ ์  ์žˆ์„ ๊ฒฝ์šฐ ๋Œ“๊ธ€ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

๋Œ“๊ธ€