错误。 org.springframework.web.context.ContextLoader - 上下文初始化失败

时间:2015-09-14 01:43:37

标签: javascript java spring spring-mvc

我正在tomcat7中部署网站(spring)但是它给出了错误 -

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/spring/root-context.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [jdbc/sqlMapper_board.xml]'; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'BoardVO'.  Cause: java.lang.ClassNotFoundException: Cannot find class: BoardVO
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5017)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5531)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

我试图多次修复此错误,但我失败了。我怎么解决这个问题? 这是我的root-context和sqlMapper.xml

根上下文

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

	<!-- Root Context: defines shared resources visible to all other web components -->

	<bean id="propertyPlaceholderConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<value>classpath:jdbc/oracle.properties</value>
		</property>
	</bean>

	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="${jdbc.driverClassName}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>

	<!-- ////////////////////// 타일즈 관련 설정 //////////////////////// -->

	<!-- 설정파일 지정하기 -->
	<bean id="tilesConfig"
		class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
		<property name="definitions">
			<list>
				<value>/WEB-INF/home_tiles.xml</value>
				<value>/WEB-INF/member_tiles.xml</value>
				<value>/WEB-INF/test_tiles.xml</value>
			</list>
		</property>
	</bean>
	<!-- 뷰를 타일즈로 지정하기 -->
	<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
		<property name="order" value="0" />
		<property name="viewClass"
			value="org.springframework.web.servlet.view.tiles2.TilesView" />
		<property name="viewNames" value=".*" />
	</bean>

	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<!-- <property name="mapperLocations" value="classpath:jdbc/sqlMapper_*.xml" 
			/> -->
		<property name="mapperLocations">
			<list>
				<value>classpath:jdbc/sqlMapper_member.xml</value>
				<value>classpath:jdbc/sqlMapper_board.xml</value>
			</list>
		</property>
	</bean>
	
	<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
		<constructor-arg ref="sqlSessionFactory" />
	</bean>

	<bean id="MemberService" class="test.com.tilesmember.service.MemberService">
	</bean>

</beans>

sqlMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="test.com.tileslayout">

	
	<sql id="where"> 
		<where>
		<if test="searchText != ''">
			<if test="searchType == 'ALL'">
			SUBJECT LIKE CONCAT('%',#{searchText},'%') OR NAME LIKE CONCAT('%',#{searchText},'%') OR CONTENT LIKE CONCAT('%',#{searchText},'%')
			</if>
			<if test="searchType == 'TITLE'">
			SUBJECT LIKE CONCAT('%',#{searchText},'%')
			</if>
			<if test="searchType == 'NAME'">
			WRITER LIKE CONCAT('%',#{searchText},'%')
			</if>
			<if test="searchType == 'CONTENT'">
			CONTENTS LIKE CONCAT('%',#{searchText},'%')
			</if>
		</if> 
		</where>
	</sql>

	<select id="selectList" parameterType="BoardVO" resultType="BoardVO">
		SELECT
			NUM
		   ,TITLE
		   ,NAME
		   ,CONTENT
		   ,HIT
		   ,REG_DATE as regDate
		FROM
			BOARD
		<include refid="where"/>
		ORDER BY NUM DESC
		LIMIT #{startIndex}, #{listCount}
	</select>
	
	<select id="selectCount" parameterType="BoardVO" resultType="int">
		SELECT COUNT(NUM) FROM BOARD
		<include refid="where"/>
	</select>
	
	<select id="select" parameterType="BoardVO" resultType="test.com.tilesmember.model.BoardVO">
		SELECT
			NUM
		   ,TITLE
		   ,NAME
		   ,CONTENT
		   ,HIT
		   ,REG_DATE as regDate
		FROM
			BOARD
		WHERE
			NUM = #{num}
	</select>
	
	<insert id="insert" parameterType="test.com.tilesmember.model.BoardVO">
		INSERT INTO BOARD (
			TITLE
		   ,NAME
		   ,CONTENT
		   ,HIT
		   ,REG_DATE
		) VALUES (
			#{title}
		   ,#{name}
		   ,#{content}
		   ,0
		   ,NOW()
		   ,NOW()
		)
	</insert>
	
	<update id="update">
		UPDATE BOARD SET 
			TITLE		= #{title}
		   ,NAME		= #{name}
		   ,CONTENT	= #{content}
		WHERE
			NUM = #{num}
	</update>

	<update id="updateHit">
		UPDATE BOARD SET HIT = HIT + 1 WHERE NUM = #{num}
	</update>

	<delete id="delete">
		DELETE FROM BOARD WHERE NUM = #{num}
	</delete>

</mapper>

0 个答案:

没有答案