package demo.action;
import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.ActionSupport;
import demo.service.DemoService;
/**
* QQ:30366040
* Demo测试类
* @author PC504
*
*/
public class DemoAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
@Autowired
private DemoService demoService;//service 利用的annotation
public DemoService getDemoService() {
return demoService;
}
public void setDemoService(DemoService demoService) {
this.demoService = demoService;
}
public String execute(){
demoService.say();
return SUCCESS;
}
}
package demo.service.impl;
import demo.dao.DemoDao;
import demo.service.DemoService;
/**
* 接口略
* @author PC504
*
*/
public class DemoServiceImpl implements DemoService {
DemoDao demoDao;
public DemoDao getDemoDao() {
return demoDao;
}
public void setDemoDao(DemoDao demoDao) {
this.demoDao = demoDao;
}
public String say(){
return demoDao.save();
}
}
package demo.dao.impl;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import demo.dao.DemoDao;
import demo.dao.entity.Demo;
/**
* 接口略
* @author PC504
*
*/
public class DemoDaoImpl extends HibernateDaoSupport implements DemoDao {
public String save(){
Demo demo = new Demo();
demo.setDemoName("say");
getHibernateTemplate().save(demo);
return null;
}
}
一下是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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"></property>
<property name="url" value="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=demo"></property>
<property name="username" value="sa"></property>
<property name="password" value="root"></property>
</bean>
</beans>
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="demoDao"
class="demo.dao.impl.DemoDaoImpl">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="demoService"
class="demo.service.impl.DemoServiceImpl">
<property name="demoDao">
<ref local="demoDao" />
</property>
</bean>
<!--Hibernate Annotation SessionFatory-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<!--常用数据库方言 MySQL5Dialect,SQLServerDialect,OracleDialect,SybaseDialect,DB2Dialect,HSQLDialect -->
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.query.substitutions">true 1, false 0</prop>
<prop key="hibernate.default_batch_fetch_size">4</prop>
</props>
</property>
<property name="mappingResources" value="demo/dao/entity/Demo.hbm.xml"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" >
<ref bean="sessionFactory"/>
</property>
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="find*" read-only="true"/>
<tx:method name="get*" read-only="true"/>
<tx:method name="query*" read-only="true"/>
<tx:method name="*" read-only="false"/>
</tx:attributes>
</tx:advice>
</beans>
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-autowire="byName" default-lazy-init="false">
<!-- component-scan自动搜索@Component , @Controller , @Service , @Repository等标注的类 -->
<!-- 默认值如果适合,该项可以不用修改 -->
<context:component-scan base-package="demo.service" />
</beans>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<package name="default" namespace="/" extends="struts-default">
<action name="demoAction" class="demo.action.DemoAction" >
<result name="success">/WEB-INF/jsp/demo/index.jsp</result>
</action>
</package>
<!-- Add packages here -->
</struts>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/applicationConfig/applicationContext-*.xml</param-value>
</context-param>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!
# For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
log4j.rootLogger=INFO,stdout
# SqlMap logging configuration...
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.logger.java.sql.ResultSet=DEBUG
log4j.logger.com.tpaic.tpfa.app.biz.dispatch.impl=ERROR
log4j.logger.java.net.SocketException=FATAL
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
#log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
# Keep three backup files.
# log4j.appender.logfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
#A6 send log info(ERROR or Fatal) by Email
#log4j.appender.A6 = com.tpaic.claim.util.SMTPExtAppender
#log4j.appender.A6.Threshold=INFO
#log4j.appender.A6.SMTPHost=tpaic-mailsrv.tpaicdom.com
#log4j.appender.A6.to=xiaojun@tpaic.com
#log4j.appender.A6.from=autoClaimAdmin@tpaic.com
#log4j.appender.A6.SMTPAuth=true
#log4j.appender.A6.SMTPUsername=oa
#log4j.appender.A6.SMTPPassword=123@tpaic
#log4j.appender.A6.Subject=AutoClaim System Error Log
#log4j.appender.A6.layout=org.apache.log4j.PatternLayout
#log4j.appender.A6.layout.ConversionPattern= [%d{HH:mm:ss}] [%t] %c - %-5p - %m%n
就弄到这里了 太晚了 该睡觉了 。终于测试成功了 。
- 大小: 63.9 KB
- 大小: 63.1 KB
- 大小: 42.2 KB
分享到:
相关推荐
hibernate3.0jar包
struts2.2.3+spring3.0.3+hibernate3.6.7整合jar包 +配置文件+整合Struts2.2与Hibernate3.6需要的Spring3.1相关JAR文件.doc+SSM config.xml.doc+mybatis-spring-1.0.0-reference-simplified-chinese.pdf
Struts2 Spring3.0 Hibernate3.3 全注解配置,避免了大量业务类在Spring文件的配置,整合了DWR3.0,displayTag 物理分页技术的实现。树形菜单。 另外数据库,在下一个资源;由于20MB的限制。 有问题的话留言。
这个"struts2.2.1+spring 3.0.3+hibernate3.6+dwr3.0全注解整合包"是将这些框架结合在一起,使用注解方式配置,简化了传统的XML配置文件,提高了开发效率和代码的可读性。以下是关于这四个框架及其整合的知识点: 1...
标题中的"MPAndroidChart-v3.0.3.jar"表明我们讨论的是该库的3.0.3版本的Java Archive (JAR) 文件,这个文件通常用于在Android Studio项目中引入依赖。 MPAndroidChart支持以下主要类型的图表: 1. 折线图(Line...
标题中的"modbus4j-3.0.3.jar.zip"是一个包含Modbus协议库的Java archive(JAR)文件的压缩包。这个文件的主要作用是为Java开发者提供了一个工具,以便他们能够轻松地在自己的应用程序中实现与使用Modbus协议的工业...
lucene-smartcn-3.0.3.jar
modbus4j
spring-security-3.0.3.jar 卷一
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
离线安装包,亲测可用
离线安装包,亲测可用
这个"spring-security-3.0.3.jar2"文件很可能是该框架的特定版本——3.0.3的组件,分为两个部分,这个是第二部分。Spring Security 3.0.3是一个较旧的版本,但它仍包含许多核心功能,例如身份验证、授权、会话管理...
离线安装包,亲测可用
离线安装包,亲测可用
官方离线安装包,亲测可用
sonar-pdfreport-plugin 已经对static 下 download.js 错误路径进行修改 sonar-pdf-plugin 3.0.3 适用SONARQUBE6.3+ ,生成 sonarqube 项目报告 report ,2积分好事成双,免去打包浪费时间
mybatis-Plus.jar 各个版本, Mybatis-Plus是一个Mybatis的增强工具,只是在Mybatis的基础上做了增强却不做改变,MyBatis-Plus支持所有Mybatis原生的特性,所以引入Mybatis-Plus不会对现有的Mybatis构架产生任何影响...
ognl-3.0.3.jar struts2要用的包