• <noscript id="ecgc0"><kbd id="ecgc0"></kbd></noscript>
    <menu id="ecgc0"></menu>
  • <tt id="ecgc0"></tt>

    如何在myeclipse中搭建ssm框架

    最簡單的ssm框架搭建方式

    東西/原料

    • 電腦
    • myeclipse8.5

    方式/步調

    1. 1

      起首呢 打開eclipse點擊左上角的File-->New-->Report Web Project

    2. 2

      然后在彈出的窗口輸入項目名稱  點擊Finish

    3. 3

      項目布局

    4. 4

      接下來呢我們直接生當作Spring 在項目上右擊 選擇 Myeclipse-->Add Spring Cababilities 之后會彈出窗口(如圖)  然后勾選JDBC(它會主動勾選三個)之后再勾選一個web3.0,再點擊finish

    5. 5

      此刻的項目布局

    6. 6

      之后我們再設置裝備擺設web.xml:

      <?xml version="1.0" encoding="UTF-8"?><web-app version="2.5"     xmlns="http://java.sun.com/xml/ns/javaee"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  <welcome-file-list>    <welcome-file>index.jsp</welcome-file>  </welcome-file-list>  <filter>          <filter-name>encoding</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>encoding</filter-name>          <url-pattern>/*</url-pattern>  </filter-mapping><!-- springmvc的焦點節制器 -->  <servlet>      <servlet-name>springDispatcher</servlet-name>      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>      <init-param>          <param-name>contextConfigLocation</param-name>          <param-value>classpath:applicationContext.xml</param-value>      </init-param>      <load-on-startup>0</load-on-startup>  </servlet>  <servlet-mapping>      <servlet-name>springDispatcher</servlet-name>      <url-pattern>*.do</url-pattern>  </servlet-mapping>  <!-- 啟動spring -->    <listener>        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>    </listener><!--拿到設置裝備擺設文件    -->     <context-param>            <param-name>contextConfigLocation</param-name>          <param-value>classpath:applicationContext.xml</param-value>     </context-param>   </web-app>

    7. 7

      然后是applicationContext.xml:

      <?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:mvc="http://www.springframework.org/schema/mvc"    xmlns:context="http://www.springframework.org/schema/context"      xmlns:tx="http://www.springframework.org/schema/tx"       xmlns:aop="http://www.springframework.org/schema/aop"      xsi:schemaLocation="http://www.springframework.org/schema/beans                         http://www.springframework.org/schema/beans/spring-beans.xsd                          http://www.springframework.org/schema/context                         http://www.springframework.org/schema/context/spring-context-3.0.xsd                          http://www.springframework.org/schema/tx                          http://www.springframework.org/schema/tx/spring-tx-3.0.xsd                          http://www.springframework.org/schema/aop                         http://www.springframework.org/schema/aop/spring-aop-3.0.xsd                        http://www.springframework.org/schema/mvc                         http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">         <!-- 開啟注解 -->    <context:annotation-config/>       <!-- 掃描包設置 -->    <context:component-scan base-package="com.tbdz.*"/>     <!-- 啟用3.0新注解 -->    <mvc:annotation-driven />        <!-- 啟動Spring MVC的注解功能,完當作請乞降注解POJO的映射 -->    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>        <!-- 設置裝備擺設數據源 -->    <context:property-placeholder location="classpath:jdbc.properties"/>    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">        <property name="username" value="${jdbc.user}"></property>        <property name="password" value="${jdbc.password}"></property>        <property name="driverClassName" value="${jdbc.driverClass}"></property>        <property name="url" value="${jdbc.url}"></property>                <property name="maxActive" value="100" ></property>        <property name="maxIdle" value="30" ></property>        <property name="maxWait" value="10000" ></property>    </bean>        <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">        <property name="dataSource" ref="dataSource"/>        <property name="configLocation" value="classpath:mybatis-config.xml"/>    </bean>        <bean id="txManager"  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">        <property name="dataSource" ref="dataSource"></property>    </bean>        <aop:config>        <aop:pointcut id="bussinessService" expression="execution(public * com.tbdz.service.*.*(..))"/>        <aop:advisor pointcut-ref="bussinessService" advice-ref="txAdvice"  />    </aop:config>        <tx:advice id="txAdvice" transaction-manager="txManager">        <tx:attributes>            <tx:method name="add*" propagation="REQUIRED"/>            <tx:method name="update*" propagation="REQUIRED" />             <tx:method name="insert*"  propagation="REQUIRED" />            <tx:method name="del*" propagation="REQUIRED" />            <tx:method name="edit*" propagation="REQUIRED" />            <tx:method name="*" propagation="REQUIRED" />        </tx:attributes>    </tx:advice>   <context:component-scan base-package="com.tbdz.*"/></beans>

    8. 8

      到這里就根基完事啦  然后再改下你本身的包名 ;再設置裝備擺設下映射文件就ok

    注重事項

    • 注重點竄包名以及數據庫
    • 發表于 2018-03-14 00:00
    • 閱讀 ( 1571 )
    • 分類:其他類型

    你可能感興趣的文章

    相關問題

    0 條評論

    請先 登錄 后評論
    admin
    admin

    0 篇文章

    作家榜 ?

    1. xiaonan123 189 文章
    2. 湯依妹兒 97 文章
    3. luogf229 46 文章
    4. jy02406749 45 文章
    5. 小凡 34 文章
    6. Daisy萌 32 文章
    7. 我的QQ3117863681 24 文章
    8. 華志健 23 文章

    聯系我們:uytrv@hotmail.com 問答工具
  • <noscript id="ecgc0"><kbd id="ecgc0"></kbd></noscript>
    <menu id="ecgc0"></menu>
  • <tt id="ecgc0"></tt>
    久久久久精品国产麻豆