快速部署SSI框架

来源:互联网 发布:线列步兵知乎 编辑:程序博客网 时间:2024/05/16 08:40

1.先准备搭建框架要使用到的架包,放到项目的lib文件夹中如下图:





2.开始配置web.xml

服务器启动时首先加载这个文件,




Spring使用ContextLoaderListener加载ApplicationContext配置信息,web应用启动的时候来初始化WebApplicationContext


Struts2配置


配置启动页面

按照上面三个步骤整个web.xml基本配置已经完成


3.配置struts.xml文件



4.配置Spting.xml文件


<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: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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"

default-autowire="byName" default-lazy-init="true">  

<!-- 该 BeanPostProcessor 将自动对标注 @Autowired 的 Bean 进行注入 -->  

<!--Spring 通过一个 BeanPostProcessor 对 @Autowired 进行解析,所以要让 @Autowired 起作用必须事先在 Spring 容器中声明 AutowiredAnnotationBeanPostProcessor Bean。   -->  

<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>


<bean id="loginForm" class="com.test.actionForm.LoginForm">

</bean>

<bean id="userForm" class="com.test.actionForm.UserForm">

</bean>

<bean id="wxclBean" class="ViewModel.Fwpg.WxclBean">

</bean>


 <!-- 配置数据源 -->

 <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">

 <!--是数据库驱动的名称  -->

  <property name="driverClassName" value = "oracle.jdbc.driver.OracleDriver"/>

  <!--数据库的地址  采用jdbc驱动oracle用thin驱动模式@地址localhost=127.0.0.1,1521是ORACLE默认端口 -->

  <property name="url" value = "jdbc:oracle:thin:@localhost:1521:ORCL" />

  <!--数据库用户名  -->

 <property name="username" value = "scott" />

 <!--数据库密码  -->

 <property name="password" value = "tiger" />

</bean>


   <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

       <property name="configLocation" value="classpath:MyBatis-Configuration.xml"/>

       <property name="dataSource" ref="dataSource" />

   </bean>


   <bean id="wxclDAO" class="org.mybatis.spring.mapper.MapperFactoryBean">

       <property name="mapperInterface" value="DAO.Fwpg.WxclDAO"/>

       <property name="sqlSessionFactory" ref="sqlSessionFactory"/>

   </bean>


   <bean id="wxclService" class="Service.Fwpg.WxclServiceImpl">

       <property name="wxclDAO" ref="wxclDAO"/>

   </bean>


  <!--配置数据库事务管理器 -->

   <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

       <property name="dataSource"><ref bean="dataSource" /></property>

   </bean>

   <!--启动spring注解功能-->

<tx:annotation-driven transaction-manager="transactionManager" />


</beans>


5.配置Mybatis.xml


<?xml version="1.0" encoding="UTF-8" ?>  

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>

<!-- 别名 -->  

<typeAliases>  

<typeAlias type="DAO.Fwpg.UserDto"  alias="UserDto"/>  

<typeAlias type="DAO.Fwpg.WxclDto"  alias="WxclDto"/>  

<typeAlias type="ViewModel.Fwpg.WxclBean"  alias="WxclBean"/>  

<typeAlias type="com.test.actionForm.UserForm"  alias="UserForm"/>  

<typeAlias type="com.test.actionForm.LoginForm"  alias="LoginForm"/>  

</typeAliases>

<mappers>

<mapper resource="DAO/Fwpg/WxclDAO.xml" />      

</mappers>

</configuration>


6.配置WxclDAO.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">


<mapper namespace="DAO.Fwpg.WxclDAO">  

<resultMap type="UserDto" id="userMap">

<id property="userId" column="userid"></id>  

<id property="userName" column="username"></id>  

<id property="password" column="password"></id>  

</resultMap>

<resultMap type="WxclDto" id="WxclMap">

<id property="wxclid" column="tbx_wxclid"></id>  

<id property="wxclmc" column="tbx_wxclmc"></id>  

<id property="cbdj" column="tbx_cbdj"></id>  

<id property="dj" column="tbx_dj"></id>  

<id property="xed" column="tbx_xed"></id>    

<id property="stime" column="stime"></id>    

<id property="tbx_type" column="tbx_type"></id>  

</resultMap>


<select id="selectUser" parameterType="UserForm" resultMap="userMap">

       SELECT

        USER_ID AS userId,

        USER_NAME  AS userName

        FROM USER_TABLE

        WHERE

        USER_ID=#{userName}

</select>

</mapper>



整个SSI框架算是基本搭建完成了


本文出自 “JAVA” 博客,请务必保留此出处http://mingxf.blog.51cto.com/7618732/1256613

0 0
原创粉丝点击