java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' befo

<pre name="code" class="html"><span style="font-size:32px;"><strong>在web.xml加入:</strong></span>



<span style="font-size:18px;">  <!-- Spring应用上下文, 理解层次化的ApplicationContext -->
  <context-param>
 		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext*.xml</param-value>
  </context-param></span>

 

</pre><p><span style="font-size:24px;"><strong>添加applicationContext.xml文件</strong></span></p><p><pre name="code" class="html"><span style="font-size:18px;"><?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"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">

	<context:annotation-config />

	<context:component-scan base-package="<span style="color:#ff0000;"><strong>package名</strong></span>">
		<context:exclude-filter type="annotation"
			expression="org.springframework.stereotype.Controller" />
	</context:component-scan>
</beans></span>
在springmvc的配置文件中添加:

<span style="font-size:18px;"><!-- 启用Spring基于annotation的DI, 使用户可以在Spring MVC中使用Spring的强大功能。 激活 @Required 
		@Autowired,JSR 250's @PostConstruct, @PreDestroy and @Resource 等标注 -->
	<context:annotation-config /></span>





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值