国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
maven搭建ssh
maven搭建ssh 收藏
今天抽空練習(xí)下用maven2+myeclipse搭建一個ssh框架,把搭建過程簡單記錄一下,以便以后方便查閱
1.準(zhǔn)備工作:jdk1.6,maven2.0.9,myeclipse6.0.1,mysql數(shù)據(jù)庫
2.jdk的安裝配置,以及maven2在eclipse里的配置網(wǎng)上的例子很多就不在重復(fù)
3.用m2搭建主項(xiàng)目工程s2shdemo,在myeclipse中點(diǎn)擊new-other-maven project-create a simple project輸入groupId,ArtifactId,在這里別的地方都可以根據(jù)自己的愛好填寫,但打包方式packaging必須選擇pom選項(xiàng)。點(diǎn)下一步后點(diǎn)擊完成即可。
4.完成web層:我在這里用的是m2的命令行搭建一個web工程,進(jìn)入cmd運(yùn)行如下命令:
mvn archetype:create -DgroupId=com.lcsssh.web.action -DartifactId=s2shdemo -DarchetypeGroupId=org.apache.struts -DarchetypeArtifactId=struts2-archetype-starter -DarchetypeVersion=2.0.11.2-SNAPSHOT -DremoteRepositories=http://people.apache.org/repo/m2-snapshot-repository 
其中有標(biāo)志的地方可以根據(jù)自己需要修改,這樣一個struts2和spring的web工程就搭建成功。
5.完成service層:在myeclipse中選擇file-other-maven module填寫module name并選擇父工程,也就是第3部你所建立起來的工程。進(jìn)入下一步就如第三步一樣填寫所需選項(xiàng),記住這里packaging應(yīng)選擇jar或其他不能用pom。
6.如第五步搭建dao層。
7.整合:以上步驟完成后開始配置,我把配置有關(guān)的文件全部放到web模塊下的resources目錄下
    配置web.xml文件,加入如下代碼
<?xml version="1.0" encoding="UTF-8"?>  
<web-app version="2.4" xmlns=" xmlns:xsi=" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee  <display-name>s2shdemo</display-name>  
 <distributable />  
 <context-param>  
  <param-name>contextConfigLocation</param-name>  
  <param-value>classpath:applicationContext.xml</param-value>  
 </context-param>  
 <listener>  
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
 </listener>  
 <filter>  
  <filter-name>struts</filter-name>  
  <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>  
  <init-param>  
   <param-name>actionPackages</param-name>  
   <param-value>cn.allwap.backend.action</param-value>  
  </init-param>  
 </filter>  
 <servlet>  
  <servlet-name>dwr</servlet-name>  
  <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>  
  <init-param>  
   <param-name>debug</param-name>  
   <param-value>true</param-value>  
  </init-param>  
 </servlet>    
 <filter>  
  <filter-name>openSession</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>  
  <filter-name>struts-cleanup</filter-name>  
  <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>  
 </filter>  
 <filter>  
  <filter-name>encodingFilter</filter-name>  
  <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
  <init-param>  
   <param-name>encoding</param-name>  
   <param-value>UTF-8</param-value>  
  </init-param>  
 </filter>  
 <filter-mapping>  
  <filter-name>encodingFilter</filter-name>  
  <url-pattern>/*</url-pattern>  
 </filter-mapping>  
 <filter-mapping>  
  <filter-name>openSession</filter-name>  
  <url-pattern>/*</url-pattern>  
 </filter-mapping>  
 <servlet-mapping>  
  <servlet-name>dwr</servlet-name>  
  <url-pattern>/dwr/*</url-pattern>  
 </servlet-mapping>  
 <filter-mapping>  
  <filter-name>struts-cleanup</filter-name>  
  <url-pattern>/*</url-pattern>  
 </filter-mapping>  
 <filter-mapping>  
  <filter-name>struts</filter-name>  
  <url-pattern>/*</url-pattern>  
 </filter-mapping>  
   <!-- Spring 刷新Introspector防止內(nèi)存泄露 -->  
    <listener>  
        <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>  
    </listener>  
  
       
    <!-- session超時定義,單位為分鐘 -->  
    <session-config>  
        <session-timeout>10</session-timeout>  
    </session-config>
 <welcome-file-list>  
  <welcome-file>index.jsp</welcome-file>  
  <welcome-file>default.jsp</welcome-file>  
  <welcome-file>index.html</welcome-file>  
 </welcome-file-list>  
</web-app>  
配置web action applicationContext-action.xml文件
<beans xmlns="  xmlns:xsi="  xmlns:aop="  xmlns: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/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
   http://www.springframework.org/schema/tx
     <bean id="helloWorldAction" class="com.lcsssh.web.action.HelloWorldAction"  scope="prototype"/>
      <bean id="adminInfoAction" class="com.lcsssh.web.action.AdminInfoAction"  scope="prototype">
       <property name="adminInfoServiceImpl" ref="adminInfoServiceImpl"/>
      </bean>
</beans>

配置業(yè)務(wù)層applicationContext-service.xml文件
<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="
 xmlns:xsi=" xmlns:lang=" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/lang  default-autowire="byName">  
  <bean id="adminInfoServiceImpl" class="com.lcsssh.service.impl.AdminInfoServiceImpl" scope="prototype">
   <property name="adminInfoDAO" ref="adminInfoDAO"></property>
  </bean> 
</beans>    
配置dao 層applicationContext-dao.xml文件
<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="
 xmlns:xsi=" xmlns:lang=" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/lang  default-autowire="byName">    
  <bean id="adminInfoDAO" class="com.lcsssh.dao.impl.AdminInfoDAO">
   <property name="sessionFactory">
    <ref bean="sessionFactory"/>
   </property>
  </bean>
</beans>
配置application.xml
<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="
 xmlns:xsi=" xmlns:lang=" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/lang  
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">  
  <property name="driverClassName">  
   <value>com.mysql.jdbc.Driver</value>  
  </property>  
  <property name="url">  
   <value>jdbc:mysql://localhost/test</value>  
  </property>  
  <property name="username">  
   <value>user</value>  
  </property>  
  <property name="password">  
   <value>123456</value>  
  </property>  
  <property name="maxActive">  
   <value>20</value>  
  </property>  
  <property name="maxIdle">  
   <value>5</value>  
  </property>  
  <property name="maxWait">  
   <value>-1</value>  
  </property>  
  <property name="defaultAutoCommit">  
   <value>true</value>  
  </property>  
 </bean>  
  
    
  
 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">  
  <property name="dataSource">  
   <ref local="dataSource" />  
  </property>     
  <property name="mappingDirectoryLocations">  
   <list>  
    <value>classpath:com/lcsssh/bo</value>  
   </list>  
  </property>     
  <property name="hibernateProperties">  
   <props>  
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>  
    <prop key="hibernate.show_sql">false</prop>  
    <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>  
    <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>  
    <prop key="hibernate.cache.use_query_cache">true</prop>  
   </props>  
  </property>  
 
 </bean>  
  <!-- dao object defintions -->
  <import resource="applicationContext-dao.xml"></import>
  <!-- business object defintions -->
  <import resource="applicationContext-service.xml"></import>
  <!-- web action object defintions -->
  <import resource="applicationContext-action.xml"></import>  
 <bean id="transactionManager"  
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
  <property name="sessionFactory">  
   <ref bean="sessionFactory" />  
  </property>  
 </bean>  
  
 <bean id="transactionInterceptor"  
  class="org.springframework.transaction.interceptor.TransactionInterceptor">  
  <property name="transactionManager" ref="transactionManager"></property>  
  <property name="transactionAttributes">  
   <props>  
    <prop key="save*">PROPAGATION_REQUIRED</prop>  
    <prop key="add*">PROPAGATION_REQUIRED</prop>  
    <prop key="set*">PROPAGATION_REQUIRED</prop>  
    <prop key="update*">PROPAGATION_REQUIRED</prop>  
    <prop key="delete*">PROPAGATION_REQUIRED</prop>  
    <prop key="register">PROPAGATION_REQUIRED</prop>          
    <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>  
    <prop key="valid*">PROPAGATION_REQUIRED,readOnly</prop>  
    <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>  
   </props>  
  </property>  
 </bean>  
 <bean  
  class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">  
  <property name="beanNames">  
   <value>*Service</value>  
  </property>  
  <property name="interceptorNames">  
   <value>transactionInterceptor</value>  
  </property>  
 </bean>  
 <bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">  
  <property name="transactionInterceptor" ref="transactionInterceptor">  
  </property>  
 </bean>  
</beans> 
所有配置文件配置完成。然后在父工程pom.xml下加入第4步創(chuàng)建的web模塊工程,主要代碼如下所示
<modules>
  <module>webProject</module>
  <module>serviceProject</module>
  <module>daoProject</module>
 </modules>
好了,到此為止所有的配置完成
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服