코딩(인텔리제이) 프로그램 실행 오류
-
게시물 수정 , 삭제는 로그인 필요
2024-05-15T16:53:31.160+09:00 ERROR 14828 --- [Projectgram] [ restartedMain] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[spring-boot-autoconfigure-3.2.5.jar:3.2.5]
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:183) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:428) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:289) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:349) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:788) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:606) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-3.2.5.jar:3.2.5]
at com.project.Projectgram.ProjectgramApplication.main(ProjectgramApplication.java:10) ~[main/:na]
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) ~[spring-boot-devtools-3.2.5.jar:3.2.5]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@36baf30c]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:483) ~[spring-core-6.1.6.jar:6.1.6]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:360) ~[spring-core-6.1.6.jar:6.1.6]
at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:417) ~[spring-core-6.1.6.jar:6.1.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$1(AbstractAutowireCapableBeanFactory.java:750) ~[spring-beans-6.1.6.jar:6.1.6]
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1740) ~[na:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:749) ~[spring-beans-6.1.6.jar:6.1.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:682) ~[spring-beans-6.1.6.jar:6.1.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:653) ~[spring-beans-6.1.6.jar:6.1.6]
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1676) ~[spring-beans-6.1.6.jar:6.1.6]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:562) ~[spring-beans-6.1.6.jar:6.1.6]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:534) ~[spring-beans-6.1.6.jar:6.1.6]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:247) ~[spring-boot-autoconfigure-3.2.5.jar:3.2.5]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:240) ~[spring-boot-autoconfigure-3.2.5.jar:3.2.5]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:230) ~[spring-boot-autoconfigure-3.2.5.jar:3.2.5]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:183) ~[spring-boot-autoconfigure-3.2.5.jar:3.2.5]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:158) ~[spring-boot-autoconfigure-3.2.5.jar:3.2.5]
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-3.2.5.jar:3.2.5]
... 20 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/servlet/Filter
at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3578) ~[na:na]
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2676) ~[na:na]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:465) ~[spring-core-6.1.6.jar:6.1.6]
... 36 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[na:na]
... 40 common frames omitted
에러 메세지가 이렇게 뜨는데 챗gpt에 물어본 결과
-
java.lang.IllegalStateException
: org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer
의 조건 처리 중 오류가 발생했습니다.
-
java.lang.IllegalStateException
: org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration
의 클래스를 분석하는 도중에 문제가 발생했습니다.
-
java.lang.NoClassDefFoundError
: javax.servlet.Filter
클래스를 찾을 수 없습니다.
-
java.lang.ClassNotFoundException
: javax.servlet.Filter
클래스를 찾을 수 없습니다.
이 오류는 주로 클래스 패스에 필요한 라이브러리가 없거나 잘못 구성되었을 때 발생합니다.
해결을 위해 다음 단계를 시도해 볼 수 있습니다:
- 프로젝트의 의존성(dependency) 설정을 확인하세요. 필요한 라이브러리가 모두 포함되어 있는지 확인하세요. 특히
javax.servlet
라이브러리가 필요한데, 이 라이브러리가 정상적으로 포함되어 있는지 확인하세요.
- 프로젝트의 설정 파일을 확인하세요. 특히
PropertyPlaceholderAutoConfiguration
및 WebSecurityConfiguration
와 관련된 설정을 다시 확인하세요.
- 프로젝트를 다시 빌드하고 실행해 보세요. 종종 이러한 종류의 문제는 라이브러리가 올바르게 포함되지 않았거나 클래스 패스가 잘못 설정되어 있을 때 발생합니다. 이렇게 답변을 해줘서 의존성을 확인해 봤는데
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security:2.6.0'
implementation 'org.springframework.security:spring-security-config:5.5.3'
implementation 'jakarta.servlet:jakarta.servlet-api:5.0.0'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
현재 의존성은 이렇게 되어있고
SecurityConfig클래스는
<div><pre>package com.project.Projectgram.web.config;
import com.project.Projectgram.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
@EnableWebSecurity// web에서 제공하는 시큐리티를 사용함
@Configuration // 스프링 컨테이너에서 싱글론(static)으로 Bean을 관리할 수 있도록 명시적으로 사용 + 객체를 하나만 사용
public class SecurityConfig {
@Autowired
private UserService service;
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.csrf().disable();
http.authorizeRequests()
.antMatchers("/", "/user/**", "/image/**", "/subscribe/**", "/comment/**", "/api/**").authenticated()
.anyRequest().permitAll()
.and()
.formLogin()
.loginPage("/auth/signin")
.loginProcessingUrl("/login")
.defaultSuccessUrl("/");
return http.build();
}
@Bean
public PasswordEncoder encoded() {
return new BCryptPasswordEncoder();
}
}
이렇게 되어있습니다 .
WebMvconfig 클래스는
<div><pre>package com.project.Projectgram.web.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.resource.PathResourceResolver;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Value("${file.path}")
private String uploadFolder;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry){
WebMvcConfigurer.super.addResourceHandlers(registry);
registry
.addResourceHandler("/upload/**") //jsp페이지에서 /upload/** 주소패턴이 나오면 작동
.addResourceLocations("file:///" + uploadFolder) //properties 에 해당하는 주소
.setCachePeriod(60 * 10 * 6) //1시간
.resourceChain(true) //를 걸어주면 발동
.addResolver(new PathResourceResolver());
}
}
이렇게 되어있고 오류 뜬곳 링크를 눌러보니
<div><pre>/**
* Signals that a method has been invoked at an illegal or
* inappropriate time. In other words, the Java environment or
* Java application is not in an appropriate state for the requested
* operation.
*
* @author Jonni Kanerva
* @since 1.1
*/
public class IllegalStateException extends RuntimeException {
/**
* Constructs an IllegalStateException with no detail message.
* A detail message is a String that describes this particular exception.
*/
public IllegalStateException() {
super();
}
/**
* Constructs an IllegalStateException with the specified detail
* message. A detail message is a String that describes this particular
* exception.
*
* @param s the String that contains a detailed message
*/
public IllegalStateException(String s) {
super(s);
}
/**
* Constructs a new exception with the specified detail message and
* cause.
*
* <p>Note that the detail message associated with {@code cause} is
* <i>not</i> automatically incorporated in this exception's detail
* message.
*
* @param message the detail message (which is saved for later retrieval
* by the {@link Throwable#getMessage()} method).
* @param cause the cause (which is saved for later retrieval by the
* {@link Throwable#getCause()} method). (A {@code null} value
* is permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.5
*/
public IllegalStateException(String message, Throwable cause) {
super(message, cause);
}
/**
* Constructs a new exception with the specified cause and a detail
* message of {@code (cause==null ? null : cause.toString())} (which
* typically contains the class and detail message of {@code cause}).
* This constructor is useful for exceptions that are little more than
* wrappers for other throwables (for example, {@link
* java.security.PrivilegedActionException}).
*
* @param cause the cause (which is saved for later retrieval by the
* {@link Throwable#getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.5
*/
public IllegalStateException(Throwable cause) {
super(cause);
}
@java.io.Serial
static final long serialVersionUID = -1848914673093119416L;
}
이렇게 되어있는데 어떻게 고쳐야 실행이 될까요 ??
-
java.lang.IllegalStateException
:org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer
의 조건 처리 중 오류가 발생했습니다. -
java.lang.IllegalStateException
:org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration
의 클래스를 분석하는 도중에 문제가 발생했습니다. -
java.lang.NoClassDefFoundError
:javax.servlet.Filter
클래스를 찾을 수 없습니다. -
java.lang.ClassNotFoundException
:javax.servlet.Filter
클래스를 찾을 수 없습니다.
이 오류는 주로 클래스 패스에 필요한 라이브러리가 없거나 잘못 구성되었을 때 발생합니다.
해결을 위해 다음 단계를 시도해 볼 수 있습니다:
- 프로젝트의 의존성(dependency) 설정을 확인하세요. 필요한 라이브러리가 모두 포함되어 있는지 확인하세요. 특히
javax.servlet
라이브러리가 필요한데, 이 라이브러리가 정상적으로 포함되어 있는지 확인하세요. - 프로젝트의 설정 파일을 확인하세요. 특히
PropertyPlaceholderAutoConfiguration
및WebSecurityConfiguration
와 관련된 설정을 다시 확인하세요. - 프로젝트를 다시 빌드하고 실행해 보세요. 종종 이러한 종류의 문제는 라이브러리가 올바르게 포함되지 않았거나 클래스 패스가 잘못 설정되어 있을 때 발생합니다. 이렇게 답변을 해줘서 의존성을 확인해 봤는데
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security:2.6.0'
implementation 'org.springframework.security:spring-security-config:5.5.3'
implementation 'jakarta.servlet:jakarta.servlet-api:5.0.0'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
현재 의존성은 이렇게 되어있고
SecurityConfig클래스는
<div><pre>package com.project.Projectgram.web.config;
import com.project.Projectgram.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
@EnableWebSecurity// web에서 제공하는 시큐리티를 사용함
@Configuration // 스프링 컨테이너에서 싱글론(static)으로 Bean을 관리할 수 있도록 명시적으로 사용 + 객체를 하나만 사용
public class SecurityConfig {
@Autowired
private UserService service;
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.csrf().disable();
http.authorizeRequests()
.antMatchers("/", "/user/**", "/image/**", "/subscribe/**", "/comment/**", "/api/**").authenticated()
.anyRequest().permitAll()
.and()
.formLogin()
.loginPage("/auth/signin")
.loginProcessingUrl("/login")
.defaultSuccessUrl("/");
return http.build();
}
@Bean
public PasswordEncoder encoded() {
return new BCryptPasswordEncoder();
}
}
이렇게 되어있습니다 .
WebMvconfig 클래스는
<div><pre>package com.project.Projectgram.web.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.resource.PathResourceResolver;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Value("${file.path}")
private String uploadFolder;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry){
WebMvcConfigurer.super.addResourceHandlers(registry);
registry
.addResourceHandler("/upload/**") //jsp페이지에서 /upload/** 주소패턴이 나오면 작동
.addResourceLocations("file:///" + uploadFolder) //properties 에 해당하는 주소
.setCachePeriod(60 * 10 * 6) //1시간
.resourceChain(true) //를 걸어주면 발동
.addResolver(new PathResourceResolver());
}
}
이렇게 되어있고 오류 뜬곳 링크를 눌러보니
<div><pre>/**
* Signals that a method has been invoked at an illegal or
* inappropriate time. In other words, the Java environment or
* Java application is not in an appropriate state for the requested
* operation.
*
* @author Jonni Kanerva
* @since 1.1
*/
public class IllegalStateException extends RuntimeException {
/**
* Constructs an IllegalStateException with no detail message.
* A detail message is a String that describes this particular exception.
*/
public IllegalStateException() {
super();
}
/**
* Constructs an IllegalStateException with the specified detail
* message. A detail message is a String that describes this particular
* exception.
*
* @param s the String that contains a detailed message
*/
public IllegalStateException(String s) {
super(s);
}
/**
* Constructs a new exception with the specified detail message and
* cause.
*
* <p>Note that the detail message associated with {@code cause} is
* <i>not</i> automatically incorporated in this exception's detail
* message.
*
* @param message the detail message (which is saved for later retrieval
* by the {@link Throwable#getMessage()} method).
* @param cause the cause (which is saved for later retrieval by the
* {@link Throwable#getCause()} method). (A {@code null} value
* is permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.5
*/
public IllegalStateException(String message, Throwable cause) {
super(message, cause);
}
/**
* Constructs a new exception with the specified cause and a detail
* message of {@code (cause==null ? null : cause.toString())} (which
* typically contains the class and detail message of {@code cause}).
* This constructor is useful for exceptions that are little more than
* wrappers for other throwables (for example, {@link
* java.security.PrivilegedActionException}).
*
* @param cause the cause (which is saved for later retrieval by the
* {@link Throwable#getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.5
*/
public IllegalStateException(Throwable cause) {
super(cause);
}
@java.io.Serial
static final long serialVersionUID = -1848914673093119416L;
}
이렇게 되어있는데 어떻게 고쳐야 실행이 될까요 ??