- 浏览: 149106 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
415421979:
我也遇到了这个问题 求解啊
JBoss/Tomcat 安装路径带空格时 JNDI 无法初始化的BUG -
ivonxiao:
谢谢楼主的分享
异常管理系统 -
ivonxiao:
谢谢楼主的分享~~
Java对象的强、软、弱和虚引用
所作项目的spring常用配置文件,结合hibernate
1.config.properties文件//配置连接数据库的参数,和Hibernate的一些参数
Java代码 复制代码
#for mysql
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://localhost:3306/***?useUnicode=true&characterEncoding=GBK
#jdbc.username=root
#jdbc.password=123
#hibernate.dialect=org.hibernate.dialect.MySQLDialect
#for hsqldb
9. #jdbc.driver=org.hsqldb.jdbcDriver
10. #jdbc.url=jdbc:hsqldb:file:/${***.root}/WEB-INF/data/***
11. #jdbc.username=sa
12. #jdbc.password=
13. #hibernate.dialect=org.hibernate.dialect.HSQLDialect
14.
15. #for oracle
16. jdbc.driver=oracle.jdbc.driver.OracleDriver
17. jdbc.url=jdbc:oracle:thin:@192.168.8.***:1521:orcl
18. jdbc.username=bmsys2
19. jdbc.password=oracle9i
20. hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
21.
22.
23. #for sql server
24. #jdbc.driver=net.sourceforge.jtds.jdbc.Driver
25. #jdbc.url=jdbc:jtds:sqlserver://localhost:1433/***;SelectMethod=cursor;
26. #jdbc.username=sa
27. #jdbc.password=zhang
28. #hibernate.dialect=org.hibernate.dialect.SQLServerDialect
29.
30. jdbc.maxActive=30
31. jdbc.maxIdle=20
32. jdbc.maxWait=1000
33.
34.
35. hibernate.show_sql=true
36. hibernate.hbm2ddl.auto=
37. hibernate.format_sql=true
38. hibernate.cache.use_query_cache=false
39. hibernate.default_batch_fetch_size=16
#for mysql
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://localhost:3306/***?useUnicode=true&characterEncoding=GBK
#jdbc.username=root
#jdbc.password=123
#hibernate.dialect=org.hibernate.dialect.MySQLDialect
#for hsqldb
#jdbc.driver=org.hsqldb.jdbcDriver
#jdbc.url=jdbc:hsqldb:file:/${***.root}/WEB-INF/data/***
#jdbc.username=sa
#jdbc.password=
#hibernate.dialect=org.hibernate.dialect.HSQLDialect
#for oracle
jdbc.driver=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@192.168.8.***:1521:orcl
jdbc.username=bmsys2
jdbc.password=oracle9i
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
#for sql server
#jdbc.driver=net.sourceforge.jtds.jdbc.Driver
#jdbc.url=jdbc:jtds:sqlserver://localhost:1433/***;SelectMethod=cursor;
#jdbc.username=sa
#jdbc.password=zhang
#hibernate.dialect=org.hibernate.dialect.SQLServerDialect
jdbc.maxActive=30
jdbc.maxIdle=20
jdbc.maxWait=1000
hibernate.show_sql=true
hibernate.hbm2ddl.auto=
hibernate.format_sql=true
hibernate.cache.use_query_cache=false
hibernate.default_batch_fetch_size=16
2.spring-config.xml; //读取config.properties,配置DataSource
Java代码 复制代码
1. <?xml version="1.0" encoding="GBK" ?>
2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3. <beans>
4. <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
5. <property name="location">
6. <value>/WEB-INF/config.properties</value>
7. </property>
8. </bean>
9. <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
10. <property name="driverClassName">
11. <value>${jdbc.driver}</value>
12. </property>
13. <property name="url">
14. <value>${jdbc.url}</value>
15. </property>
16. <property name="username">
17. <value>${jdbc.username}</value>
18. </property>
19. <property name="password">
20. <value>${jdbc.password}</value>
21. </property>
22. <property name="maxActive">
23. <value>${jdbc.maxActive}</value>
24. </property>
25. <property name="maxIdle">
26. <value>${jdbc.maxIdle}</value>
27. </property>
28. <property name="maxWait">
29. <value>${jdbc.maxWait}</value>
30. </property>
31. </bean>
32. </beans>
<?xml version="1.0" encoding="GBK" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>/WEB-INF/config.properties</value>
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>${jdbc.driver}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property name="maxActive">
<value>${jdbc.maxActive}</value>
</property>
<property name="maxIdle">
<value>${jdbc.maxIdle}</value>
</property>
<property name="maxWait">
<value>${jdbc.maxWait}</value>
</property>
</bean>
</beans>
3.spring-hibernate.xml;//配置sessionFactory,transactionManager
Java代码 复制代码
1. <?xml version="1.0" encoding="GBK" ?>
2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3. <beans>
4. <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
5. <property name="dataSource">
6. <ref bean="dataSource" />
7. </property>
8. <property name="mappingResources">
9. <list>
10. <value>com/../*.hbm.xml</value>
11. </list>
12. </property>
13. <property name="hibernateProperties">
14. <props>
15. <prop key="hibernate.dialect">${hibernate.dialect}</prop>
16. <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
17. <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
18. <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
19. <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
20. <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
21. <prop key="hibernate.connection.useUnicode">true</prop>
22. <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
23. <prop key="hibernate.default_batch_fetch_size">${hibernate.default_batch_fetch_size}</prop>
24. </props>
25. </property>
26. </bean>
27. <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
28. <property name="sessionFactory">
29. <ref bean="sessionFactory" />
30. </property>
31. </bean>
32. </beans>
<?xml version="1.0" encoding="GBK" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>com/../*.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.connection.useUnicode">true</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
<prop key="hibernate.default_batch_fetch_size">${hibernate.default_batch_fetch_size}</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
4.spring-dao.xml;//配置所有Dao
Java代码 复制代码
1. <?xml version="1.0" encoding="GBK" ?>
2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3. <beans>
4. <!-- Finance-->
5. <bean id="xxxDao" class="com.xxx.XXXDAOHbm">
6. <property name="sessionFactory">
7. <ref bean="sessionFactory" />
8. </property>
9. </bean>
10. </beans>
<?xml version="1.0" encoding="GBK" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- Finance-->
<bean id="xxxDao" class="com.xxx.XXXDAOHbm">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
5.spring-service.xml;//配置service,声明事务,继承baseTransactionProxy
Java代码 复制代码
1. <?xml version="1.0" encoding="GBK" ?>
2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3. <beans>
4. <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
5. <property name="transactionManager" ref="transactionManager" />
6. <property name="transactionAttributes">
7. <props>
8. <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
9. <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
10. <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
11. <prop key="create*">PROPAGATION_REQUIRED</prop>
12. <prop key="update*">PROPAGATION_REQUIRED</prop>
13. <prop key="delete*">PROPAGATION_REQUIRED</prop>
14. <prop key="set*">PROPAGATION_REQUIRED</prop>
15. <prop key="add*">PROPAGATION_REQUIRED</prop>
16. <prop key="remove*">PROPAGATION_REQUIRED</prop>
17. <prop key="increase*">PROPAGATION_REQUIRED</prop>
18. <prop key="init*">PROPAGATION_REQUIRED</prop>
19. <prop key="back*">PROPAGATION_REQUIRED</prop>
20. <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
21. </props>
22. </property>
23. </bean>
24.
25. <!-- service implements -->
26. <bean id="XXXService" parent="baseTransactionProxy">
27. <property name="target">
28. <bean class="com.XXX.XXXServiceImpl">
29. <property name="sessionFactory">
30. <ref bean="sessionFactory" />
31. </property>
32. <property name="xxxDao">
33. <ref bean="xxxDao" />//所包含Dao
34. </property>
35. <property name="commonService">
36. <ref bean="otherService" />//所包含service
37. </property>
38. </bean>
39. </property>
<property name="proxyTargetClass">
<value>true</value>
</property>
40. </bean>
41. </beans>
注意上面要加上
<property name="proxyTargetClass">
<value>true</value>
</property>
这段,都则会出错。
1.config.properties文件//配置连接数据库的参数,和Hibernate的一些参数
Java代码 复制代码
#for mysql
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://localhost:3306/***?useUnicode=true&characterEncoding=GBK
#jdbc.username=root
#jdbc.password=123
#hibernate.dialect=org.hibernate.dialect.MySQLDialect
#for hsqldb
9. #jdbc.driver=org.hsqldb.jdbcDriver
10. #jdbc.url=jdbc:hsqldb:file:/${***.root}/WEB-INF/data/***
11. #jdbc.username=sa
12. #jdbc.password=
13. #hibernate.dialect=org.hibernate.dialect.HSQLDialect
14.
15. #for oracle
16. jdbc.driver=oracle.jdbc.driver.OracleDriver
17. jdbc.url=jdbc:oracle:thin:@192.168.8.***:1521:orcl
18. jdbc.username=bmsys2
19. jdbc.password=oracle9i
20. hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
21.
22.
23. #for sql server
24. #jdbc.driver=net.sourceforge.jtds.jdbc.Driver
25. #jdbc.url=jdbc:jtds:sqlserver://localhost:1433/***;SelectMethod=cursor;
26. #jdbc.username=sa
27. #jdbc.password=zhang
28. #hibernate.dialect=org.hibernate.dialect.SQLServerDialect
29.
30. jdbc.maxActive=30
31. jdbc.maxIdle=20
32. jdbc.maxWait=1000
33.
34.
35. hibernate.show_sql=true
36. hibernate.hbm2ddl.auto=
37. hibernate.format_sql=true
38. hibernate.cache.use_query_cache=false
39. hibernate.default_batch_fetch_size=16
#for mysql
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://localhost:3306/***?useUnicode=true&characterEncoding=GBK
#jdbc.username=root
#jdbc.password=123
#hibernate.dialect=org.hibernate.dialect.MySQLDialect
#for hsqldb
#jdbc.driver=org.hsqldb.jdbcDriver
#jdbc.url=jdbc:hsqldb:file:/${***.root}/WEB-INF/data/***
#jdbc.username=sa
#jdbc.password=
#hibernate.dialect=org.hibernate.dialect.HSQLDialect
#for oracle
jdbc.driver=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@192.168.8.***:1521:orcl
jdbc.username=bmsys2
jdbc.password=oracle9i
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
#for sql server
#jdbc.driver=net.sourceforge.jtds.jdbc.Driver
#jdbc.url=jdbc:jtds:sqlserver://localhost:1433/***;SelectMethod=cursor;
#jdbc.username=sa
#jdbc.password=zhang
#hibernate.dialect=org.hibernate.dialect.SQLServerDialect
jdbc.maxActive=30
jdbc.maxIdle=20
jdbc.maxWait=1000
hibernate.show_sql=true
hibernate.hbm2ddl.auto=
hibernate.format_sql=true
hibernate.cache.use_query_cache=false
hibernate.default_batch_fetch_size=16
2.spring-config.xml; //读取config.properties,配置DataSource
Java代码 复制代码
1. <?xml version="1.0" encoding="GBK" ?>
2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3. <beans>
4. <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
5. <property name="location">
6. <value>/WEB-INF/config.properties</value>
7. </property>
8. </bean>
9. <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
10. <property name="driverClassName">
11. <value>${jdbc.driver}</value>
12. </property>
13. <property name="url">
14. <value>${jdbc.url}</value>
15. </property>
16. <property name="username">
17. <value>${jdbc.username}</value>
18. </property>
19. <property name="password">
20. <value>${jdbc.password}</value>
21. </property>
22. <property name="maxActive">
23. <value>${jdbc.maxActive}</value>
24. </property>
25. <property name="maxIdle">
26. <value>${jdbc.maxIdle}</value>
27. </property>
28. <property name="maxWait">
29. <value>${jdbc.maxWait}</value>
30. </property>
31. </bean>
32. </beans>
<?xml version="1.0" encoding="GBK" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>/WEB-INF/config.properties</value>
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>${jdbc.driver}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property name="maxActive">
<value>${jdbc.maxActive}</value>
</property>
<property name="maxIdle">
<value>${jdbc.maxIdle}</value>
</property>
<property name="maxWait">
<value>${jdbc.maxWait}</value>
</property>
</bean>
</beans>
3.spring-hibernate.xml;//配置sessionFactory,transactionManager
Java代码 复制代码
1. <?xml version="1.0" encoding="GBK" ?>
2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3. <beans>
4. <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
5. <property name="dataSource">
6. <ref bean="dataSource" />
7. </property>
8. <property name="mappingResources">
9. <list>
10. <value>com/../*.hbm.xml</value>
11. </list>
12. </property>
13. <property name="hibernateProperties">
14. <props>
15. <prop key="hibernate.dialect">${hibernate.dialect}</prop>
16. <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
17. <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
18. <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
19. <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
20. <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
21. <prop key="hibernate.connection.useUnicode">true</prop>
22. <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
23. <prop key="hibernate.default_batch_fetch_size">${hibernate.default_batch_fetch_size}</prop>
24. </props>
25. </property>
26. </bean>
27. <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
28. <property name="sessionFactory">
29. <ref bean="sessionFactory" />
30. </property>
31. </bean>
32. </beans>
<?xml version="1.0" encoding="GBK" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>com/../*.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.connection.useUnicode">true</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
<prop key="hibernate.default_batch_fetch_size">${hibernate.default_batch_fetch_size}</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
4.spring-dao.xml;//配置所有Dao
Java代码 复制代码
1. <?xml version="1.0" encoding="GBK" ?>
2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3. <beans>
4. <!-- Finance-->
5. <bean id="xxxDao" class="com.xxx.XXXDAOHbm">
6. <property name="sessionFactory">
7. <ref bean="sessionFactory" />
8. </property>
9. </bean>
10. </beans>
<?xml version="1.0" encoding="GBK" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- Finance-->
<bean id="xxxDao" class="com.xxx.XXXDAOHbm">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
5.spring-service.xml;//配置service,声明事务,继承baseTransactionProxy
Java代码 复制代码
1. <?xml version="1.0" encoding="GBK" ?>
2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3. <beans>
4. <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
5. <property name="transactionManager" ref="transactionManager" />
6. <property name="transactionAttributes">
7. <props>
8. <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
9. <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
10. <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
11. <prop key="create*">PROPAGATION_REQUIRED</prop>
12. <prop key="update*">PROPAGATION_REQUIRED</prop>
13. <prop key="delete*">PROPAGATION_REQUIRED</prop>
14. <prop key="set*">PROPAGATION_REQUIRED</prop>
15. <prop key="add*">PROPAGATION_REQUIRED</prop>
16. <prop key="remove*">PROPAGATION_REQUIRED</prop>
17. <prop key="increase*">PROPAGATION_REQUIRED</prop>
18. <prop key="init*">PROPAGATION_REQUIRED</prop>
19. <prop key="back*">PROPAGATION_REQUIRED</prop>
20. <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
21. </props>
22. </property>
23. </bean>
24.
25. <!-- service implements -->
26. <bean id="XXXService" parent="baseTransactionProxy">
27. <property name="target">
28. <bean class="com.XXX.XXXServiceImpl">
29. <property name="sessionFactory">
30. <ref bean="sessionFactory" />
31. </property>
32. <property name="xxxDao">
33. <ref bean="xxxDao" />//所包含Dao
34. </property>
35. <property name="commonService">
36. <ref bean="otherService" />//所包含service
37. </property>
38. </bean>
39. </property>
<property name="proxyTargetClass">
<value>true</value>
</property>
40. </bean>
41. </beans>
注意上面要加上
<property name="proxyTargetClass">
<value>true</value>
</property>
这段,都则会出错。
发表评论
-
Spring+hibernate的单元测试Junit
2008-01-24 15:05 1162spring提供的单元测试是强大的,spring的单元测试很简 ... -
使用import简化spring的配置文件
2008-01-14 18:47 4906对于spring配置文件的编写,我想,对于经历过庞大项目的人, ... -
spring的事务配置
2008-01-14 16:47 1023Spring通过AOP实现声明式事务管理。通常通过Trans ... -
数据源配置
2008-01-14 15:53 922对于不同的数据库存取需求,我们使用JDBC来解决这个问题,对于 ... -
spring配置
2008-01-14 14:24 1163在web.xml中的<web-app>节点下定义 ...
相关推荐
### Spring常用配置详解 #### 一、控制反转(IOC) 控制反转(Inversion of Control, IOC)是Spring框架的核心特性之一,它改变了以往程序中的对象创建和管理方式。在传统的编程模式下,对象间的依赖关系是由对象自身...
】案例解地址案例 案例解地址测试4 Spring基础配置测试5 Spring基础配置测试6AOP Spring基础配置测试6AOP Spring基础配置Test7-Scope Spring常用配置Test8-EL Spring常用配置Test9-BeanLiftCycle Spring常用配置Test...
Spring常用配置及解析类说明 Spring Framework是当前最流行的Java EE应用程序框架之一,它提供了强大的配置机制,允许开发者灵活地配置应用程序。春天的配置机制是基于XML文件的,它提供了多种配置方式,包括基于...
在这个名为"spring常用jar包"的压缩包中,包含了一些Spring框架运行所必需的核心库。下面我们将逐一解析这些jar包的功能和重要性。 1. aspectjrt.jar:这是AspectJ运行时库,用于支持面向切面编程(AOP)。AOP是...
10. **Spring Boot**:简化了Spring应用程序的初始设置和运行过程,通过自动配置和“起步依赖”使得创建独立运行的Spring应用程序更加便捷。 以上只是Spring框架部分核心模块的简要介绍,每个模块都包含了大量的类...
26. `org.springframework.boot`:Spring Boot,简化了Spring应用的初始设置和配置,提供了自动配置和"起步依赖"。 这26个包构成了Spring框架的核心,它们相互协作,为开发者提供了强大的功能和灵活性,使得在Java...
这个“Spring常用包”包含了Spring框架中最为常用的部分,适合初学者和开发者快速上手。 1. **Spring Core**: - **Bean Factory**:它是Spring的核心,负责管理对象的生命周期和依赖关系,通过XML或注解配置来...
在Spring中,配置文件通常为XML格式,如`applicationContext.xml`,它定义了bean的实例化、属性设置、装配关系等。当我们启动Spring容器(如ClassPathXmlApplicationContext),容器会解析这个XML文件,生成相应的...
1. **基于XML的全局事务配置**:这种方式通过在Spring配置文件中设置`<tx:advice>`和`<aop:config>`元素来实现事务管理。相比于第一种方式,这种方式更加简洁,适用于所有业务逻辑Bean。 2. **基于注解的事务配置**...
Spring框架是Java开发中最常用的轻量级框架之一,它的出现极大地简化了企业级应用的开发。本篇文章将针对Spring框架的常用模块进行详细介绍,旨在帮助初学者理解和掌握Spring的核心概念。 1. **IoC(控制反转)与DI...
这个"spring常用架包"集合了Spring框架中常用的核心组件,方便开发者在项目中快速引用。以下是对这些核心组件及其功能的详细介绍: 1. **Spring Core**:这是Spring框架的基础,提供依赖注入(Dependency Injection...
在Spring Boot项目中,我们可以在配置文件中这样设置: ``` spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.druid.initial-size=5 spring.datasource.druid.min-idle=5 ...
虽然SSH与Spring DWR不是直接关联,但它们都是Java企业级开发中常用的组件。SSH框架组合可以帮助构建模型-视图-控制器(MVC)架构的应用,而DWR则作为Ajax通信的工具,增强了SSH应用的交互性。如果你正在使用SSH框架...
本篇将详细介绍标题“使用spring环境常用jar”所涵盖的关键知识点。 1. **Spring IOC(Inversion of Control)**:Spring的IOC容器负责创建对象、管理对象之间的关系,它将对象的创建和维护权交给了框架,从而降低...
这个"Spring常用的jar包.rar"文件包含了一系列Spring框架的核心组件和依赖,使得开发者能够快速搭建一个基于Spring的项目环境。以下是对这些jar包及其重要性的详细解释: 1. **spring-core.jar**:这是Spring框架的...
这里需要配置Spring的IoC容器,声明Bean并设置其依赖。对于Struts2,Spring可以通过`struts-plugin.xml`与Struts2进行集成,提供Action的依赖注入。此外,还需要配置Spring的数据源、事务管理器以及JPA的实体扫描...
Spring框架是Java开发中最常用的轻量级框架之一,它的核心在于IoC(Inversion of Control,控制反转)和AOP(Aspect Oriented Programming,面向切面编程)。在本压缩包中,你将找到Spring4版本的相关jar包,这些是...
以上就是 Spring 2.5 中的一些核心知识点,这个压缩包中的“spring常用包”可能包含了实现这些功能的相关类库和配置文件。学习和掌握这些内容,将有助于你更好地利用 Spring 2.5 构建高效、可维护的 Java 应用程序。
Spring框架是Java开发中最常用的轻量级框架之一,它的核心在于IoC(Inversion of Control,控制反转)和AOP(Aspect Oriented Programming,面向切面编程)。在本压缩包中,你可能会找到一系列与Spring相关的jar包,...
在 Java 领域中,Spring Integration 和 Spring WS 是两个常用的框架,它们分别负责集成系统和 Web 服务。今天,我们将探讨如何将这两个框架整合在一起,实现一个完整的 Web 服务解决方案。 Spring Integration ...