applicationContext.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:aop="http://www.springframework.org/schema/aop" 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/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- 用注解方法注入bean 上边schemaLocation的三条语句顺序很重要,否则报错 -->
<context:annotation-config />
<context:component-scan base-package="com" /> <!-- 数据库连接池 -->
<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?useUnicode=true&amp;characterEncoding=UTF-8" />
<property name="username" value="root" />
<property name="password" value="123456" />
</bean> <!-- 配置sessionFactory ,数据库配置在hibernate.cfg.xml中-->
<!--LocalSessionFactoryBean 加载bean方式 <mapping resource="com/model/User.hbm.xml"/>
AnnotationSessionFactoryBean 加载bean方式 <mapping class="com.model.User"/> ,它主要功能是取消了hbm.xml文件
-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 配置实体描述文件 -->
<property name="mappingResources">
<list>
<value>com/model/User.hbm.xml</value>
</list>
</property>
<!--扫描com.cuangwu包下以及子包种有 @Service @Controller @Repository @Component 注解的类,一旦发现,则将其纳入到spring容器中管理
此spring.jar必须是 Spring2.5以上版本的,因为,Spring2.5之前org.springframework.orm.hibernate3.LocalSessionFactoryBean类中,
并没有 packageToScan 这个属性,只有mappingResuorces这个属性。而packageToScan这个属性正是映射包中的类,而mappingResuorces只是映射某个文件。-->
<!-- <property name="packagesToScan" > <list> <value>com.model</value>
</list> </property> -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbn2dd1.auto">update</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="find*" read-only="true" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!-- aop代理设置-->
<aop:config>
<aop:pointcut expression="execution(public * com.service..*.*(..))"
id="myPointcut" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="myPointcut" />
</aop:config> </beans>

struts.xml

<?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.i18n.encoding" value="UTF-8" />
<package name="struts2" extends="struts-default" namespace="/">
<!-- 配置action当与spring整合,class=bean的名称(如果bean没有指定value,则首写字母要小写)) -->
<action name="add" class="userAction" method="addUser" >
<result name="success">success.jsp</result>
<result name="error">fail.jsp</result>
</action>
<action name="query" class="userAction" method="queryUser">
<result name="success">index.jsp</result>
</action>
<action name="delete" class="userAction" method="deleteUser">
<result name="success">success.jsp</result>
<result name="error">fail.jsp</result>
</action>
<action name="edit" class="userAction" method="editUser">
<result name="editUser">editUser.jsp</result>
<result name="success">success.jsp</result>
</action>
</package>
</struts>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- 用来定位Spring XML文件的上下文位置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- spring监听 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 过滤器将 Hibernate Session 绑定到请求线程中,它将自动被 Spring 的事务管理器探测到 -->
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>false</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

User.hbm.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping>
<class name="com.model.User" table="user" catalog="mydb">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="assigned"></generator>
</id>
<property name="username" type="java.lang.String">
<column name="username" length="30" not-null="true" unique="true"/>
</property>
<property name="userpassword" type="java.lang.String">
<column name="userpassword" length="30" not-null="true" />
</property>
<property name="usermessage" type="java.lang.String">
<column name="usermessage" length="30" />
</property>
</class>
</hibernate-mapping>

【 SSH 配置参考】的更多相关文章

  1. mysql+ssh 配置(转载)

    Mysql+ssh配置 一.Linux平台间mysql+ssh配置 本机地址为:192.168.189.133 mysql服务器地址为:192.168.189.139 linux命令行下使用ssh命令 ...

  2. SSH配置免密登录

    [参考文章]:linux服务器ssh免密码登录 [参考文章]:ssh分发秘钥时出现错误“Permission denied (publickey,gssapi-keyex,gssapi-with-mi ...

  3. Gitlab的SSH配置(linux和windows双版本)

    1. 步骤 1.首先现在电脑端安装好git,windows端请安装Git for Windows,Linux端请自行网上查询(Ubuntu: sudo apt-get install git)   2 ...

  4. Linux服务器配置---ssh配置

    Ssh配置     通过配置文件,我们可以有效的管理ssh 1.空闲时间关闭连接 1)修改配置文件“/etc/ssh/sshd_config”,设置clientAliveInterval和client ...

  5. Sftp搭建与配置参考

    Sftp搭建与配置参考 1. 介绍 sftp是Secure File Transfer Protocol的缩写,安全文件传送协议.可以为传输文件提供一种安全的加密方法.sftp 与 ftp 有着几乎一 ...

  6. SSH配置免秘钥登录

    一.  SSH 配置免秘要登录 配置SSH 免秘要登录,虽然就那么几步,但总是会出现点小问题,今天就做下记录.SSH 免秘钥就是让两台机器相互信任,不需要输入密码就能相互登录.配置相互信任就是把各自的 ...

  7. RHEL/CentOS通用性能优化、安全配置参考

    RHEL/CentOS通用性能优化.安全配置参考 本文的配置参数是笔者在实际生产环境中反复实践总结的结果,完全适用绝大多数通用的高负载.安全性要求的网络服务器环境.故可以放心使用. 若有异议,欢迎联系 ...

  8. Ngrok远程桌面及ssh配置

    上一篇Ngrok 内网穿透利器 使用教程我们讲到Ngrok的基本使用教程,这篇描述一下Ngrok的远程桌面及ssh配置 Step 1 修改配置文件ngrok.cfg server_addr: &quo ...

  9. centos ssh配置使用

    配置 数据阶梯 CentOS SSH配置 默认CentOS已经安装了OpenSSH,即使你是最小化安装也是如此.所以这里就不介绍OpenSSH的安装了. SSH配置: 1.修改vi /etc/ssh/ ...

随机推荐

  1. Verilog-格雷码加法器

    1.概述 格雷码执行加1操作最多只会变1位,可用在多位地址指针中消除毛刺. 2.verilog代码 `timescale 1ns / 1ps module gray_adder #() ( input ...

  2. ubantu安装apache

    1.命令安装: sudo apt install apache2 2.检查是否启动了Apache服务 systemctl status apache2 3.开启.关闭和重启服务器 /etc/init. ...

  3. 论文阅读笔记(五)【CVPR2012】:Large Scale Metric Learning from Equivalence Constraints

    由于在读文献期间多次遇见KISSME,都引自这篇CVPR,所以详细学习一下. Introduction 度量学习在机器学习领域有很大作用,其中一类是马氏度量学习(Mahalanobis metric ...

  4. [P5490] 【模板】扫描线 - 线段树

    求 \(n\) 个矩形的面积并 Solution 将矩形转化为 \(y_1\) 位置的 + 修改 和 \(y_2\) 位置的 - 修改.然后按照 \(+y\) 顺序依次处理所有的修改,到达的一个新的位 ...

  5. spring boot MySQL Public Key Retrieval is not allowed

    建议在链接url处添加对应的属性 jdbc:mysql://localhost:3306/book?allowPublicKeyRetrieval=true&useSSL=false 

  6. MySQL 中like的使用对于索引的影响

    今天看了一篇对于like使用对索引的影响的文章,发现自己实践的跟文章得出结论不大一样.所以还是建议自己再看别人文章的时候自己亲自动手实践一下.以免学到不全面的知识. 列子: 先建立一张表: -- 创建 ...

  7. C++中多态实现的关键——虚函数

    1.多态的作用 在面向对象程序设计中,使用多态能够增强代码的可扩充性,,即程序需要增加或修改部分功能时,只需修改少量代码就能够达到目的,此外多态也能起到精简代码的作用. 而实现多态的关键点,就是虚函数 ...

  8. ddctf,warm up,web题

    1,打开链接,发现下图,hhhh好滑稽啊,鹅鹅鹅鹅ee 2,打开源码发现source.php.添加到路径,再次访问,发现如下代码,来,让我们审计一下. 3,发现有个hint.php,进去看一看,得到一 ...

  9. 835. 字符串统计(Trie树模板题)

    维护一个字符串集合,支持两种操作: “I x”向集合中插入一个字符串x: “Q x”询问一个字符串在集合中出现了多少次. 共有N个操作,输入的字符串总长度不超过 105105,字符串仅包含小写英文字母 ...

  10. 题解【洛谷P1379】八数码难题

    题面 典型的\(\text{BFS}\). 双向广搜是一种对\(\text{BFS}\)的优化,它适用于起点和终点都明确的题目. 这里给出我的双向广搜模板. inline int bfs()//双向广 ...