從零開(kāi)始搭建ssm項(xiàng)目(一)環(huán)境配置

其實(shí)在網(wǎng)上看到許多spring+springmvc+mybatis項(xiàng)目的攻略,ssm項(xiàng)目也是所有項(xiàng)目里頭比較基礎(chǔ)的項(xiàng)目了。自己手動(dòng)做一個(gè),也相當(dāng)于溫故一下以前學(xué)習(xí)過(guò)的知識(shí),在途中可能會(huì)踩到許多坑,我會(huì)把這些坑都一一記錄在這里,同時(shí)也會(huì)尋根究底,在項(xiàng)目過(guò)程中盡量通過(guò)源碼挖掘出ssm契合的奧妙之處。

話不多說(shuō),let's do it!(這文章是用markdown寫(xiě)的,覺(jué)得挺好用的,發(fā)現(xiàn)簡(jiǎn)書(shū)也支持,就嘗試著玩一下)

首先,我用的是 eclipse Version: Neon.3 Release (4.6.3)
可能這個(gè)版本比較老了,不過(guò)我比較懶,沒(méi)去更新,就醬吧。
jdk我用的是 jdk1.8.0_77。
數(shù)據(jù)庫(kù)我用的是mysql


maven我用的是 apache-maven-3.3.9
maven里面我用的是阿里云的鏡像庫(kù),里面包含著很多jar包的資源了,也在這里分享下。

<mirrors>
        <mirror>
            <id>nexus-aliyun</id>
            <mirrorOf>*</mirrorOf>
            <name>Nexus aliyun</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
        </mirror>
</mirrors> 

環(huán)境準(zhǔn)備完畢,現(xiàn)在正式開(kāi)始在eclipse上搭建ssm項(xiàng)目!

eclipse點(diǎn)擊 File --> New --> Maven Project

project建好以后,在pom.xml加入maven配置
注意,你要配好user settings咯,這里的配置就是我的maven包apache-maven-3.3.9/conf下面的settings.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.cc</groupId>
  <artifactId>simpleSSM</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  <dependencies>
        <!-- 單元測(cè)試 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
        </dependency>

        <!-- 1.日志 -->
        <!-- 實(shí)現(xiàn)slf4j接口并整合 -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.1</version>
        </dependency>

        <!-- 2.數(shù)據(jù)庫(kù) -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.37</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>

        <!-- DAO: MyBatis -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>1.2.3</version>
        </dependency>

        <!-- 3.Servlet web -->
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.5.4</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>

        <!-- 4.Spring -->
        <!-- 1)Spring核心 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>4.1.7.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>4.1.7.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.1.7.RELEASE</version>
        </dependency>
        <!-- 2)Spring DAO層 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>4.1.7.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>4.1.7.RELEASE</version>
        </dependency>
        <!-- 3)Spring web -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.1.7.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.1.7.RELEASE</version>
        </dependency>
        <!-- 4)Spring test -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>4.1.7.RELEASE</version>
        </dependency>

        <!-- redis客戶端:Jedis -->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.7.3</version>
        </dependency>
        <dependency>
            <groupId>com.dyuproject.protostuff</groupId>
            <artifactId>protostuff-core</artifactId>
            <version>1.0.8</version>
        </dependency>
        <dependency>
            <groupId>com.dyuproject.protostuff</groupId>
            <artifactId>protostuff-runtime</artifactId>
            <version>1.0.8</version>
        </dependency>

        <!-- Map工具類(lèi) -->
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2</version>
        </dependency>
    </dependencies>
    
    <build>
        <finalName>ssm</finalName>
    </build>
</project>

導(dǎo)入完pom文件,我們開(kāi)始搭建整體的框架,如下圖


下一篇請(qǐng)點(diǎn)擊閱讀 http://www.itdecent.cn/p/00b5633b8477

未完待續(xù),后續(xù)更多內(nèi)容歡迎關(guān)注


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容