標籤:屬性 -name hbm enc 讀取 div figure factor http
關於mySql 的 jdbc.properties
1 jdbc.driverClassName=com.mysql.jdbc.Driver2 jdbc.url=jdbc:mysql://localhost:3306/ue_project3 jdbc.username=root4 jdbc.password=huashow
ssh中的application.xml配置
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:context="http://www.springframework.org/schema/context" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5 xmlns:aop="http://www.springframework.org/schema/aop" 6 xmlns:util="http://www.springframework.org/schema/util" 7 xmlns:tx="http://www.springframework.org/schema/tx" 8 xsi:schemaLocation=" 9 http://www.springframework.org/schema/context 10 http://www.springframework.org/schema/context/spring-context.xsd 11 http://www.springframework.org/schema/beans 12 http://www.springframework.org/schema/beans/spring-beans.xsd 13 http://www.springframework.org/schema/aop 14 http://www.springframework.org/schema/aop/spring-aop.xsd 15 http://www.springframework.org/schema/util 16 http://www.springframework.org/schema/util/spring-util.xsd17 http://www.springframework.org/schema/tx 18 http://www.springframework.org/schema/tx/spring-tx.xsd19 "> 20 <!-- 讀取jdbc.properties設定檔 -->21 <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">22 <property name="locations" value="classpath:jdbc.properties"/>23 </bean>24 <!-- 配置jdbc的dataSource -->25 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">26 <property name="driverClassName" value="${jdbc.driverClassName}"/>27 <property name="url" value="${jdbc.url}"></property>28 <property name="username" value="${jdbc.username}"></property>29 <property name="password" value="${jdbc.password}"></property>30 </bean>31 <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">32 <property name="dataSource" ref="dataSource"/>33 <property name="mappingResources">34 <list>35 <value>/com/hnqy/entity/Admin.hbm.xml</value>36 <value>/com/hnqy/entity/Figure.hbm.xml</value>37 <value>/com/hnqy/entity/Goodsdetail.hbm.xml</value>38 <value>/com/hnqy/entity/Ordermanager.hbm.xml</value>55 </list>56 </property>57 <property name="hibernateProperties">58 <value>59 hibernate.dialect=org.hibernate.dialect.MySQLDialect60 hibernate.show_sql=true61 hibernate.format_sql=true62 </value>63 </property>64 </bean>65 <!-- 定義hiberntateTemplate所在的bean -->66 <bean name="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">67 <property name="sessionFactory" ref="sessionFactory"></property>68 </bean>69 <!-- 定義事務所在的bean -->70 <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">71 <property name="sessionFactory" ref="sessionFactory"></property>72 </bean>73 <!-- 定義事務的屬性 -->74 <tx:advice id="txAdvice" transaction-manager="transactionManager">75 <tx:attributes>76 <!-- read-only="true" 交易隔離等級最低,效能最高 -->77 <tx:method name="list*" read-only="true"/>78 <tx:method name="find*" read-only="true"/>79 <tx:method name="get*" read-only="true"/>80 <!-- 除了上面定義的方法之外,其他方法都要通過交易處理 -->81 <tx:method name="*"/>82 </tx:attributes>83 </tx:advice>84 <!-- 定義事務所使用的切入點 -->85 <aop:config>86 <aop:pointcut expression="execution(* com.hnqy.service.impl.*.*(..))" id="pointcut"/>87 <aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut"/>88 </aop:config>89 <!-- 匯入SSH建立bean的檔案-->90 <import resource="bean.xml"/>91 </beans>
(附帶web.xml配置)
1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> 3 <display-name>store</display-name> 4 <welcome-file-list> 5 <welcome-file>index.html</welcome-file> 6 <welcome-file>index.htm</welcome-file> 7 <welcome-file>index.jsp</welcome-file> 8 9 </welcome-file-list>10 <!-- filter過濾器,控制session在view中開啟、關閉 一定要放到struts的filter上面-->11 <filter>12 <filter-name>OpenSessionInViewFilter</filter-name>13 <filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>14 </filter>15 <filter-mapping>16 <filter-name>OpenSessionInViewFilter</filter-name>17 <url-pattern>/*</url-pattern>18 </filter-mapping>19 20 <!-- 配置struts的核心過濾器 -->21 <filter>22 <filter-name>struts2</filter-name>23 <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>24 </filter>25 <filter-mapping>26 <filter-name>struts2</filter-name>27 <url-pattern>*.action</url-pattern>28 </filter-mapping>29 <!-- 應用啟動載入spring設定檔 指定設定檔位置-->30 <context-param>31 <param-name>contextConfigLocation</param-name>32 <param-value>classpath:beans.xml</param-value>33 </context-param>34 <!-- 配置spring的監聽器 -->35 <listener>36 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>37 </listener>38 </web-app>
ssh中的application.xml配置