<listener> <listener-
class>org.springframework.web.context.ContextLoaderListener</
listener-class>
</listener>
5、在 applicaonContext.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:jee="http://www.springframework.org/schema/jee"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-
beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-
2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-
jee-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-
2.5.xsd"
default-lazy-init="true">
<!-- 使用 annotation 自动注册 bean,并检查@Required,@Autowired 的属性已被
注入 -->
<context:annotation-config/>
<context:component-scan base-package="com.login"/>
<bean
class="org.springframework.beans.factory.annotation.AutowiredAnnotati
onBeanPostProcessor" />
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"
/>
<property name="url" value="jdbc:mysql://localhost:3306/mydb"
/>
<property name="username" value="root" />
- 1
- 2
- 3
前往页