SSM(SpringMvc+mybatis+Spring)java web搭建工程__【開發工具】Eclipse-J2EE

來源:互聯網
上載者:User
No.1   首先將web工程結構建好 1.1.1 開發環境介紹

 在這裡我是採用的是MySQL資料庫 

  編譯器版本採用的是jdk使用的是1.8

 開發工具是使用的是eclipse Mars版本

  web容器採用的是tomcat 版本是7.0版本   

  在這裡我將我自己寫好的Demo工程目錄結構截圖展示出來方便大家建立項目

這張圖圖片清晰地將我的工程清晰地展示出來,先簡單介紹下吧 ,項目主包是以com.cntv開始的 。在之下又分為好幾個子包,分別是mapper、controller、service、dao、mapper、logs、config、base、entity、test包,其中controller包是負責接收前台請求執行部分商務邏輯的action,熟悉struts架構的應該知道Action哈 在這裡我就不詳細說了。mapper包主要是負責mybatis架構實體映射,config包是主要儲存項目設定檔。  其他的包就不一一介紹了,都是些常規的包。

  NO.2  準備好相應的jar包 這裡我是採用Spring是.2.0版本 mybatis是3.3.0版本的   圖中框選的jar包是一些依賴性jar包   不要以為這就是完整的jar包   還有呢....

 

到此為止 jar包已準備完畢  現在就來開始準備架構的相關的配置了  首先是spring+mybatis關聯的配置 NO.3 組態架構相關功能的設定檔

在src目錄中config檔案夾中建立spring-mybatis.xml檔案 ,通過這個檔案整合並關聯Spring+mybatis架構

  <span style="font-size: 14px;"><</span><span style="font-size:18px;">?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:p="http://www.springframework.org/schema/p"       xmlns:context="http://www.springframework.org/schema/context"       xmlns:mvc="http://www.springframework.org/schema/mvc"       xsi:schemaLocation="http://www.springframework.org/schema/beans             http://www.springframework.org/schema/beans/spring-beans-3.1.xsd             http://www.springframework.org/schema/context             http://www.springframework.org/schema/context/spring-context-3.1.xsd             http://www.springframework.org/schema/mvc             http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">       <span style="color:#ff0000;"><!-- 自動掃描 --></span>       <context:component-scan base-package="com.cntv" />       <span style="color:#ff0000;"><!-- 引入設定檔 --></span>       <bean id="propertyConfigurer"           class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">           <property name="location" value="classpath:jdbc.properties" />       </bean>          <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"           destroy-method="close">           <property name="driverClassName" value="${driver}" />           <property name="url" value="${url}" />           <property name="username" value="${username}" />           <property name="password" value="${password}" />           <span style="color:#ff0000;"><!-- 初始化串連大小 --></span>           <property name="initialSize" value="${initialSize}"></property>           <span style="color:#ff0000;"><!-- 串連池最大數量 --></span>           <property name="maxActive" value="${maxActive}"></property>           <span style="color:#ff0000;"><!-- 串連池最大空閑 --></span>           <property name="maxIdle" value="${maxIdle}"></property>           <span style="color:#ff0000;"><!-- 串連池最小空閑 --></span>           <property name="minIdle" value="${minIdle}"></property>           <span style="color:#ff0000;"><!-- 擷取串連最大等待時間 --></span>           <property name="maxWait" value="${maxWait}"></property>       </bean>          <span style="color:#ff0000;"><!-- spring和MyBatis完美整合,不需要mybatis的配置對應檔 --></span>       <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">           <property name="dataSource" ref="dataSource" />           <span style="color:#ff0000;"><!-- 自動掃描mapping.xml檔案 --></span>           <property name="mapperLocations" value="classpath:com/cntv/mapper/*.xml"></property>       </bean>          <span style="color:#ff0000;"><!-- DAO介面所在包名,Spring會自動尋找其下的類 --></span>       <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">           <property name="basePackage" value="com.cn.hnust.dao" />           <property name=

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.