sshspring配置文件|谁能跟我具体的说说java ssh框架中几个配置文件的具体关系和区别

|

❶ ssh 项目中 spring配置文件中 <bean id="TeacherAction" class="….."></bean> 我没有写

这很正常。。。你用的ssh框架 别忘了 里面还有个struts2这东西也有动态代理的功能的可以创建action对象的。。。既然你没在spring中配 说明你把action的创建交给struts2了就像你单独使用struts2 你自己也没有new action啊 不也照样使用了

❷ 谁能跟我具体的说说java ssh框架中几个配置文件的具体关系和区别

先说说他们分别配置些什么吧web.xml 是web工程必须的,项目启动时首先加载web.xml文件,读取配置相关信息。applicationContext.xml 是spring框架的配置信息 ,关于bean的注入,以及事物管理等信息struts.xml 是struts2框架的配置信息,关于action和result的值struts-config.xml 是struts1的配置信息hibernate.cfg.xml 是hibernate框架的配置信息,当然有了applicationContext.xml 可以放在里面, 也可以在applicationContext.xml 里引用 hibernate.cfg.xml 。 <bean id="sf" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"></property> </bean>

❸ ssh spring配置问题

首先:spring.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"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-2.5.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"><!– 引入属性文件 –><context:property-placeholder location="classpath:config.properties" /><!– 自动扫描和service包(自动注入) –><context:component-scan base-package="zy.,zy.service" /></beans>————————————————————————————————-接着:spring-hibernate.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"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-2.5.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"><!– JNDI方式配置数据源 –><!– <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="${jndiName}"></property> </bean> –><!– 配置数据源 –><!– 配置数据源 –><bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"><property name="url" value="${jdbc_url}" /><property name="username" value="${jdbc_username}" /><property name="password" value="${jdbc_password}" /><!– 初始化连接大小 –><property name="initialSize" value="0" /><!– 连接池最大使用连接数量 –><property name="maxActive" value="20" /><!– 连接池最大空闲 –><property name="maxIdle" value="20" /><!– 连接池最小空闲 –><property name="minIdle" value="0" /><!– 获取连接最大等待时间 –><property name="maxWait" value="60000" /><!– <property name="poolPreparedStatements" value="true" /> <property name="" value="33" /> –><property name="validationQuery" value="${validationQuery}" /><property name="testOnBorrow" value="false" /><property name="testOnReturn" value="false" /><property name="testWhileIdle" value="true" /><!– 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 –><property name="timeBetweenEvictionRunsMillis" value="60000" /><!– 配置一个连接在池中最小生存的时间,单位是毫秒 –><property name="minEvictableIdleTimeMillis" value="25200000" /><!– 打开removeAbandoned功能 –><property name="removeAbandoned" value="true" /><!– 1800秒,也就是30分钟 –><property name="removeAbandonedTimeout" value="1800" /><!– 关闭abanded连接时输出错误日志 –><property name="logAbandoned" value="true" /><!– 监控数据库 –><!– <property name="filters" value="stat" /> –><property name="filters" value="mergeStat" /></bean><!– 配置hibernate session工厂 –> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"><property name="dataSource" ref="dataSource" /><property name="hibernateProperties"><props><prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop><prop key="hibernate.dialect">${hibernate.dialect}</prop><prop key="hibernate.show_sql">${hibernate.show_sql}</prop><prop key="hibernate.format_sql">${hibernate.format_sql}</prop></props></property><!– 自动扫描注解方式配置的hibernate类文件 –><property name="packagesToScan"><list><value>zy.model</value></list></property><!– 自动扫描hbm方式配置的hibernate文件和.hbm文件 –><!– <property name="mappingDirectoryLocations"><list><value>classpath:sy/hbm</value></list></property> –></bean><!– 配置事务管理器 –><bean name="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean><!– 注解方式配置事物 –><!– <tx:annotation-driven transaction-manager="transactionManager" /> –><!– 拦截器方式配置事物 –><tx:advice id="transactionAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="add*" /><tx:method name="save*" /><tx:method name="update*" /><tx:method name="modify*" /><tx:method name="edit*" /><tx:method name="delete*" /><tx:method name="remove*" /><tx:method name="repair" /><tx:method name="deleteAndRepair" /><tx:method name="get*" propagation="SUPPORTS" /><tx:method name="find*" propagation="SUPPORTS" /><tx:method name="load*" propagation="SUPPORTS" /><tx:method name="search*" propagation="SUPPORTS" /><tx:method name="datagrid*" propagation="SUPPORTS" /><tx:method name="*" propagation="SUPPORTS" /></tx:attributes></tx:advice><aop:config><aop:pointcut id="transactionPointcut" expression="execution(* zy.service..*Impl.*(..))" /><aop:advisor pointcut-ref="transactionPointcut" advice-ref="transactionAdvice" /></aop:config><!– hiebernate中的hibernateTemplate模板方法 –> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <!– 给HibernateTemplate类中注入 sessionFactory获得实例–><property name="sessionFactory" ref="sessionFactory"></property></bean></beans>

❹ java web 开发,使用ssh框架,在我的Spring配置文件中有下面的配置

这是配置Spring的事务。其中:<tx:methodname="add*"propagation="REQUIRED"/>表示以add开头的方法,开启REQUIRED事务。其中REQUIRED为事务传播机制的类型。关于事务传播机制:PROPAGATION_REQUIRED如果当前没有事务,就新建一个事务,如果已经存在一个事务中,加入到这个事务中。这是最常见的选择。PROPAGATION_SUPPORTS支持当前事务,如果当前没有事务,就以非事务方式执行。PROPAGATION_MANDATORY使用当前的事务,如果当前没有事务,就抛出异常。PROPAGATION_REQUIRES_NEW新建事务,如果当前存在事务,把当前事务挂起。PROPAGATION_NOT_SUPPORTED以非事务方式执行操作,如果当前存在事务,就把当前事务挂起。PROPAGATION_NEVER以非事务方式执行,如果当前存在事务,则抛出异常。PROPAGATION_NESTED如果当前存在事务,则在嵌套事务内执行。如果当前没有事务,则执行与PROPAGATION_REQUIRED类似的操作。

❺ 使用ssh开发web应用时,spring配置文件中需要添加哪些配置信息

主要是得配置hibernate的数据库连接的各种属性。还有spring,自己的配置属性。另外,struts2的话, 有的可能耦合性强一点,也在spring的配置中,把代替struts2的工厂配置出来。也有的struts2用自己的工厂的话, 就不用怎么配置了好像。

❻ 关于SSH中Spring配置好的SessionFactory(已经在Spring配置文件中配好)不用注解(@Resource)要怎么获取。

<bean name="HibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory" /></bean>在你第一个类private HibernateTemplate ht;添加set()方法将上面<bean>注入到其中使用:43 行可以改成 ht.save(entity)根据意思你试下吧

❼ java—ssh—spring配置文件里的配置问题

Spring配置DAO层,可以直接在applicationContext-db.xml进行配置,示例如下:两个DAO的定义,通常声明DAO的时候,都是用接口来声明来使spring注入 <bean id="txn1001BO" name="txn1001BO" class="dap.service.bo.validate.impl.AuthReqBOImpl" scope="prototype"> <property name="commonOnlDAO" ref="commonOnlDAO"/> <property name="commonHisDAO" ref="commonHisDAO"/>定义bo层的操作时,需要注入的DAO定义 </bean>


赞 (0)