1、首先配置ssh免密 *** 作
Linux 下实现SSH互信: https://www.jianshu.com/p/2456d98aa607
2、简单命令
ssh root@192.168.1.1 "cd /var/liblscd "
2.1 使用时注意,双引号必须有。若没加双引号,第二条及之后的命令会在本地执行
2.2 分号是将两条语句间隔开
2.3 单双引的区别:单引号不会解析值,是什么就传什么;双引号会解析值,将解析结果传过去
3、多条命令
ssh root@192.168.1.1<<reallssh
cd /var/lib/test
tar -zxvf api.com.tar.gz
......
exit
reallssh
3.1 命令写在 << reallssh(开始) 至 reallssh(结束) 之间
3.2 reallssh可自己定义为其他形式
3.3 在结束前加上exit退出远程
4、可能遇到的问题
问题:远程登录主机时出现Pseudo-terminal will not be allocated because stdin is not a terminal. 错误
解决方案:字面意思是伪终端将无法分配,因为标准输入不是终端。
所以需要增加-t -t参数来强制伪终端分配,即使标准输入不是终端。
to force pseudo-tty allocation even if stdin isn’t a terminal.
参考样例如下:
ssh -t -t user1@192.168.1.1 -p 22
--------------------------------------------------------------------------------
参考:https://blog.csdn.net/jinking01/article/details/84386769
您好,这样的:在applicationContext.xml中配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="palceHolderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
abstract="false" singleton="true" lazy-init="default"
autowire="default" dependency-check="default">
<property name="location">
<value>classpath:init.properties</value>
</property>
</bean>
<!--c3p0数据源配置-->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" dependency-check="default">
<property name="driverClass">
<value>${dataSource.driver}</value>
</property>
<property name="jdbcUrl">
<value>${dataSource.jdbcUrl}</value>
</property>
<property name="user">
<value>${dataSource.user}</value>
</property>
<property name="password">
<value>${dataSource.password}</value>
</property>
<property name="acquireIncrement">
<value>${dataSource.acquireIncrement}</value>
</property>
<property name="minPoolSize">
<value>${dataSource.minPoolSize}</value>
</property>
<property name="maxPoolSize">
<value>${dataSource.maxPoolSize}</value>
</property>
<property name="maxIdleTime">
<value>${dataSource.maxIdleTime}</value>
</property>
<property name="idleConnectionTestPeriod">
<value>${dataSource.idleConnectionTestPeriod}</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<!-- 显示sql语句 -->
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/vo/Customer.hbm.xml</value>
<value>com/vo/Engineer.hbm.xml</value>
<value>com/vo/Repairplant.hbm.xml</value>
<value>com/vo/Product.hbm.xml</value>
<value>com/vo/Archives.hbm.xml</value>
<value>com/vo/Account.hbm.xml</value>
<value>com/vo/User.hbm.xml</value></list>
</property>
</bean>
<bean id="engineerDAO" class="com.dao.impl.EngineerDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="repairplantDAO" class="com.dao.impl.RepairplantDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="productDAO" class="com.dao.impl.ProductDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="archivesDAO" class="com.dao.impl.ArchivesDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="accountDAO" class="com.dao.impl.AccountDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="userDAO" class="com.dao.impl.UserDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="customerDAO" class="com.dao.impl.CustomerDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
这样就可以在调试的时候显示sql语句了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)