SSH配置文件

SSH整合有多种方式,我的方式:

 

把所有配置文件放到一个Config目录下。

 

Hibernate配置文件:

 

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>

<session-factory>
 <property name="dialect">
  org.hibernate.dialect.MySQLDialect
 </property>
 <property name="connection.url">
  jdbc:mysql://localhost:3306/test
 </property>
 <property name="connection.username">root</property>
 <property name="connection.password">root</property>
 <property name="connection.driver_class">
  com.mysql.jdbc.Driver
 </property>
 <property name="myeclipse.connection.profile">mysql</property>
 <property name="show_sql">true</property>
 <property name="jdbc.fetch_size">50</property>
 <property name="jdbc.batch_size">30</property>
 <property name="hbm2ddl.auto">update</property>
 <property name="current_session_context_class">thread</property>

 <!-- 加入映射文件-->
</session-factory>

</hibernate-configuration>

 

Spring配置文件:

<?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"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
 http://www.springframework.org/schema/aop
 http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

 <bean id="sessionFactory"
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="configLocation"
   value="classpath:hibernate/hibernate.cfg.xml">
  </property>
 </bean>
 
 <!-- 事务配置开始 -->
 <bean id="transactionManager"
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
   <ref local="sessionFactory"/>
  </property>
 </bean>
 <tx:advice id="txAdvice" transaction-manager="transactionManager">
  <tx:attributes>
   <tx:method name="add*" propagation="REQUIRED"/>
   <tx:method name="save*" propagation="REQUIRED"/>
   <tx:method name="del*" propagation="REQUIRED"/>
   <tx:method name="update*" propagation="REQUIRED"/>
   <tx:method name="*" read-only="true"/>
  </tx:attributes>
 </tx:advice>
 
 <aop:config>
  <aop:pointcut id="allManagerMethod" expression="execution (* <!--自定义-->*.*(..))"/>
  <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
 </aop:config>
 <!-- 事务配置结束 -->
 
 <!-- bean配置开始 -->


  <!-- bean配置开始 -->
 <!-- Struts配置开始 -->


  <!-- Struts配置结束 -->
</beans>

 

Struts配置文件:

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
  <data-sources />
  <form-beans>
   <form-bean name="orgForm" type="com.derek.oa.web.form.OrgForm"/>
  </form-beans>
  <global-exceptions>
    </global-exceptions>
  <global-forwards>
  </global-forwards>
  <action-mappings>
   <action path="/orgAction"
    name="orgForm"
    type="org.springframework.web.struts.DelegatingActionProxy"
    input="/orgnization/index.jsp"
    parameter="method">
    <forward name="index" path="/orgnization/index.jsp" redirect="false"/>
    </action>
  </action-mappings>
  <message-resources parameter="struts.ApplicationResources" />
</struts-config>

注意:org.springframework.web.struts.DelegatingActionProxy

而且不能配置plugin

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
   <set-property property="contextConfigLocation" value="classpath:spring/*.xml"/>
  </plug-in>

 

 

web.xml配置:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
  <!-- Struts配置 -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/classes/struts/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>3</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>3</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
 
  <!-- Spring配置 -->
  <context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>classpath:spring/*.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
 
  <!-- OpenSession过滤器 -->
  <filter>
   <filter-name>opensession</filter-name>
   <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
  </filter>
  <filter-mapping>
   <filter-name>opensession</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>
 
  <!-- 字符过滤器 -->
  <filter>
   <filter-name>characterfilter</filter-name>
   <filter-class>com.derek.oa.util.filter.SetCharacterEncodingFilter</filter-class>
   <init-param>
    <param-name>encoding</param-name>
    <param-value>GBK</param-value>
   </init-param>
  </filter>
  <filter-mapping>
    <filter-name>characterfilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
 
  <!-- 首页 -->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
 
  <!-- 标签配置 -->
  <jsp-config>
   <taglib>
    <taglib-uri>/tags/struts-html</taglib-uri>
    <taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>
   </taglib>
   <taglib>
    <taglib-uri>/tags/struts-bean</taglib-uri>
    <taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
   </taglib>
   <taglib>
    <taglib-uri>/tags/struts-logic</taglib-uri>
    <taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
   </taglib>
   <taglib>
    <taglib-uri>/tags/struts-nested</taglib-uri>
    <taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location>
   </taglib>
   <taglib>
    <taglib-uri>/tags/struts-tiles</taglib-uri>
    <taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>
   </taglib>
  </jsp-config>
</web-app>

 

sping2+struts1x+hibernate3成功!

<think>好的,我现在需要帮用户查找关于SSH配置文件的信息,包括示例、教程、格式以及ssh_config的相关内容。首先,用户提到的引用来源中有几个关键点需要整理。 首先,用户引用了创建和修改SSH配置文件的步骤。比如引用[1]和[2]提到在用户目录下的.ssh文件夹中创建config文件,并设置权限为600,这很重要,因为SSH对文件权限有严格要求。然后,引用[3]提到了修改/etc/ssh/sshd_config来更改SSH服务器的配置,比如端口号。引用[4]则涉及SCP命令,虽然与配置文件无直接关联,但可能用户对相关工具有兴趣。 接下来,我需要确定用户的需求是什么。用户明确想要SSH配置文件的示例、教程、格式以及ssh_config的内容。可能需要解释配置文件的结构,常见配置项,以及如何应用这些配置。同时,用户可能需要知道如何编辑配置文件,包括客户端和服务器的不同配置文件。 考虑到用户可能对客户端配置文件更感兴趣,因为问题中提到了config文件的创建和示例。需要分步骤说明如何创建配置文件,每个配置项的作用,比如Host、HostName、User、Port、IdentityFile等。同时,提供示例配置,让用户能够直观地理解格式。 此外,权限设置是关键点,必须提醒用户将config文件的权限设置为600,否则SSH会拒绝使用,这是常见的问题点。教程部分需要涵盖基本配置和高级用法,比如多主机配置、代理跳转等。 关于服务器端配置,用户提到修改sshd_config,比如更改端口,禁止root登录,这些也是常见的安全优化步骤。需要区分客户端配置(ssh_config)和服务器配置(sshd_config),避免混淆。 最后,生成相关问题需要考虑用户可能的后续疑问,比如权限问题、配置不生效的原因,以及如何测试配置是否正确。这样可以帮助用户进一步解决问题,而不仅仅是提供基本信息。</think>### SSH配置文件使用指南 1. **配置文件位置** - 客户端配置文件:`~/.ssh/config`(用户级)或`/etc/ssh/ssh_config`(系统级) - 服务端配置文件:`/etc/ssh/sshd_config`[^3] 2. **基本格式规范** ```config Host 别名 HostName 主机地址 User 用户名 Port 端口号 IdentityFile 密钥路径 ProxyJump 跳板机别名 ``` 3. **配置示例** ```config # 基础连接配置 Host myserver HostName 192.168.1.100 User admin Port 2222 # 带密钥认证的配置 Host github HostName github.com User git IdentityFile ~/.ssh/github_key ``` 4. **关键配置参数** | 参数 | 作用 | 示例 | |------|------|------| | `Host` | 配置块标识 | `Host *.example.com` | | `ForwardAgent` | SSH代理转发 | `ForwardAgent yes` | | `StrictHostKeyChecking` | 密钥检查策略 | `StrictHostKeyChecking no` | 5. **操作步骤** ```bash # 创建配置文件 mkdir -p ~/.ssh && touch ~/.ssh/config chmod 600 ~/.ssh/config # 必须设置权限[^1] # 验证配置语法 ssh -T -F ~/.ssh/config 别名 ``` 6. **服务器配置修改** 修改`/etc/ssh/sshd_config`后需执行: ```bash sudo systemctl reload sshd # 重载配置[^3] ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值