[ 스프링 오류] org.springframework.beans.factory.BeanCreationException

2022. 4. 17. 00:09Error

컨트롤러 연결하는 과정에서 memebrService를 사용라는 도중에 발생한 오류다.

 

memberDAO로 수정하여 돌려보니 연결이 잘 되는데 

memebrService로 할때만 에러가 발생하였다.

 

해결방법을 알아보자!

 


 

 

에러 발생 문구 :

 

org.springframework.beans.factory.BeanCreationException

org.springframework.web.servlet.DispatcherServlet - Context initialization failed

 

 


해결방법 : web.xml에 경로설정과 리스너를 추가하였더니 문제가 해결되었다. 

 

   <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:applicationContext.xml</param-value>
   </context-param>
   <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
   </listener>

 

< 전체 코드 >

 

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://Java.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

	<filter>
		<filter-name>encFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter
		</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>encFilter</filter-name>
		<url-pattern>*.do</url-pattern>
	</filter-mapping>

	<servlet>
		<servlet-name>DispatcherServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet
		</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>DispatcherServlet</servlet-name>
		<url-pattern>*.do</url-pattern>
	</servlet-mapping>

   <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:applicationContext.xml</param-value>
   </context-param>
   <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
   </listener>
   
</web-app>