๐จ conversionServicePostProcessor Bean ์ค๋ณต ์ค๋ฅ
A bean with that name has already been defined in class path resource
Description: The bean 'conversionServicePostProcessor', defined in class path resource [org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class] and overriding is disabled. Action: Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
๐ฅ ์ค๋ฅ ์์ธ
Spring Security์์ WebFluxSecurityConfiguration๊ณผ WebSecurityConfiguration์ด ๋์์ ๋ก๋๋๋ฉด์,
conversionServicePostProcessor Bean์ด ์ค๋ณต ๋ฑ๋ก๋์ด ์ถฉ๋ํ๋ ๋ฌธ์ !
๐ก ์ฆ, WebFlux(๋ฆฌ์กํฐ๋ธ)์ MVC(๋ธ๋กํน)๊ฐ ํผ์ฉ๋๋ฉด์ ์ถฉ๋์ด ๋ฐ์!
๐ ํด๊ฒฐ ๋ฐฉ๋ฒ
1๏ธโฃ ๊ฐ์ ๋ก Bean ๋ฎ์ด์ฐ๊ธฐ ํ์ฉ
๐ก ์ด ๋ฐฉ๋ฒ์ ๊ฐ์ ๋ก ๋ฎ์ด์ฐ๊ธฐ ๋๋ฌธ์, ์ถฉ๋์ ํด๊ฒฐํ๋ ๊ทผ๋ณธ์ ์ธ ๋ฐฉ๋ฒ์ ์๋!
๐ YAML ์ฌ์ฉ ์
spring:
main:
allow-bean-definition-overriding: true
๐ Properties ์ฌ์ฉ ์
spring.main.allow-bean-definition-overriding=true
2๏ธโฃ ์์กด์ฑ ํ์ธ
pom.xml์์ spring-boot-starter-web๊ณผ spring-boot-starter-webflux๊ฐ ํจ๊ป ํฌํจ๋์๋์ง ํ์ธ
<dependencies>
<!-- ๐จ WebFlux์ ์ถฉ๋ ๊ฐ๋ฅ, ํ์ ์์ผ๋ฉด ์ ๊ฑฐ! -->
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency> -->
<!-- โ
์ผ๋ฐ MVC(Spring Web) ์ฌ์ฉ ์ -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- โ
Spring Security ์ถ๊ฐ -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
3๏ธโฃ Security ์ค์ ํ์ธ (Security Config)
@EnableWebSecurity(Spring MVC)์ @EnableWebFluxSecurity(Spring WebFlux)์ฌ์ฉ ํ์ธ. ๋๋ค import๋์ด ์๊ฑฐ๋ ํ๊ฒฝ์ ๋ง์ง ์๋ ๊ฒ ์ฌ์ฉํ๋์ง ํ์ธ.
๐ MVC(Spring Web) ์ฌ์ฉ ์
@EnableWebSecurity
public class SecurityConfig {
// Security ์ค์
}
๐ WebFlux ์ฌ์ฉ ์
@EnableWebFluxSecurity
public class SecurityConfig {
// Security ์ค์
}
'Backend > spring' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JAVA] ์ฟ ํค(Cookie) ์ค์ ๋ฐฉ๋ฒ (0) | 2025.02.23 |
---|---|
[Spring Security] CSRF & CORS ๊ฐ๋ ๋ฐ ์ค์ ๋ฐฉ๋ฒ (0) | 2025.02.23 |
[Spring Security] Web vs WebFlux Spring Security ์ค์ (0) | 2025.02.23 |
web vs webflux (0) | 2025.02.23 |
[Spring Security] Spring Security ์์ ๊ณ์ (0) | 2025.02.23 |