spring的配置文件怎么写

2024-12-12 14:27:29
推荐回答(4个)
回答1:

标准的Spring配置文件编写:


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
default-autowire="byName" default-lazy-init="true">


class="org.springframework.jdbc.datasource.DriverManagerDataSource">

com.mysql.jdbc.Driver



jdbc:mysql://localhost/ssh?characterEncoding=utf-8



root


123




class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">





com/ssh/pojo/User.hbm.xml




true





class="org.springframework.orm.hibernate3.HibernateTransactionManager">






class="org.springframework.orm.hibernate3.HibernateTemplate">






class="com.ssh.dao.impl.UserDaoImpl">




class="com.ssh.service.impl.UserServiceImpl">




class="com.ssh.action.UserAction" scope="prototype">




回答2:


xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">















org.hibernate.dialect.MySQLDialect
true




beans/Users.hbm.xml



















就是action层调用service层 service层调用dao层 dao层调用sessionFactory sessionFactory调用datasource

回答3:


这是最基本的

回答4:

帮助文档收里面很详细的介绍了