스프링 시큐리티를 설정하던 도중 만난 오류이다.

No grammar constraints (DTD or XML Schema) referenced in the document.라는 경고와 함께 발생하였다.

서버에서 DTD에 선언한 http://www.springframework.org/schema/beans에 접근하지 못하는 경우 생기는 에러라고 한다.

에러 발생 시 네임스페이스 

xmlns:beans="http://www.springframework.org/schema/beans"

 수정 후 네임스페이스

xmlns="http://www.springframework.org/schema/beans"

 

문제 해결에 도움이 된 글 : https://gdtbgl93.tistory.com/112

security-context.xml 설정 시 네임스페이스에서 문제가 발생하는 경우 해결법

1. 에러 메세지 (Error Message)

Multiple annotations found at this line:
	- You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd or spring-security-3.1.xsd schema or spring-security-3.2.xsd schema or spring-security-4.0.xsd schema with Spring 
	 Security 4.2. Please update your schema declarations to the 4.2 schema.
	- Configuration problem: You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd or spring-security-3.1.xsd schema or spring-security-3.2.xsd schema or spring-security-4.0.xsd 
	 schema with Spring Security 4.2. Please update your schema declarations to the 4.2 schema. Offending resource: file [C:/Users/berry/eclipse-workspace/sendAGift_202005/SendAGift_202005/src/
	 main/webapp/WEB-INF/spring/security-context.xml]

 

2. 해결 전

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:security="http://www.springframework.org/schema/security"
	xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-5.0.xsd">

xsi:schemaLocation의 주소를 변경해줍니다.

http://www.springframework.org/schema/security/spring-security-5.0.xsd

아래와 같이 5.0 버전 표기를 삭제합니다.

http://www.springframework.org/schema/security/spring-security.xsd

 

3. 해결 후

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:security="http://www.springframework.org/schema/security"
	xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">

 

참고 사이트 : https://stackoverrun.com/ko/q/10928899

 

1. UTF-8 / 한글 인코딩 설정 추가

	<!-- UTF-8 / 한글 인코딩 설정 -->
	<filter>
	    <filter-name>encoding-filter</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>
	    <init-param>
	        <param-name>forceEncoding</param-name>
	        <param-value>true</param-value>
	    </init-param>
	</filter>
	<filter-mapping>
	    <filter-name>encoding-filter</filter-name>
	    <url-pattern>/*</url-pattern>
	</filter-mapping>

 

2. 스프링 웹 시큐리티(Spring Web Security) 설정

 

1) 상단 contextConfigLocation에 작성한 security-context.xml을 로딩하도록 설정

	<servlet>
		<servlet-name>appServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>
			/WEB-INF/spring/appServlet/servlet-context.xml 
			/WEB-INF/spring/security-context.xml
			</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>

2) 필터 추가

	<!-- 스프링 웹 시큐리티 관련 설정 -->
	<filter>
		<filter-name>springSecurityFilterChain</filter-name>
		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>springSecurityFilterChain</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

 

 

 

 




Unsatisfied dependency expressed through field 'dao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.violet.persistence.ItemDAO' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}



DAOImpl 구현 시 클래스 위에  @Repository 어노테이션을 빼먹어서 발생한 오류였다.

어노테이션을 제대로 작성하였는지 확인할 것!





${org.springframework-version}에는 pom.xml 상단의 <properties>항목에 정의된 <org.springframework-version>버전의 값이 들어가게 된다.

이 경우에는 5.0.7.RELEASE이 된다.

+ Recent posts