IDEA14建立Maven管理的SpringMVC+Mybatis,web項目java
勾選Create from archetypemysql
點擊Nextweb
點擊Nextspring
點擊Finish,完成基本項目建立sql
在main上右鍵new Directory並命名爲java;apache
同時在Project Structure中,將java目錄設置爲Sources,而後Apply,點擊OK。spring-mvc
能夠在maven倉庫進行相關依賴搜索:http://www.mvnrepository.com/tomcat
利用<dependency>元素進行項目所依賴的jar包配置,maven經過對pom.xml的配置使得再也不須要導入jar包那麼麻煩mybatis
IDEA的maven項目中,默認源代碼目錄下的xml等資源文件並不會在編譯的時候一塊打包進classes文件夾,而是直接捨棄掉。mvc
項目中可能包含一些靜態資源如:mapping/*.xml,又或者一些spring的配置文件:spring.xml、spring-mvc.xml等等。這些靜態資源都要配置到target目錄下才能保證項目運行,不然會報找不到運行所需的這些文件。
target目錄設置,以下圖:
pom.xml在resources中配置靜態資源文件的目錄:
<resources> <!-- 該配置很重要,用於將directory下的資源複製到classpath下面。即target/classes下面--> <resource> <targetPath>whu/edu/irlab/mapping/</targetPath> <directory>src/main/java/whu/edu/irlab/mapping/</directory> <includes> <include>*.xml</include> </includes> </resource> <resource> <directory>src/main/resources</directory> </resource> </resources>
在pom.xml配置後能夠看見target目錄以下,配置的靜態資源文件被包含進來了
注: 在WEB-INFO/lib下存放有jstl.jar和standard.jar,須要將其導入項目的Libraries中(通常使用Maven不這樣作,直接在pom.xml裏面配置響應的jar包依賴就行,當時自動填補依賴有些問題故採起比較麻煩的方式作)
如圖:
<?xml version="1.0" encoding="UTF-8"?> <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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <packaging>war</packaging> <name>MavenDemo</name> <groupId>MavenDemo</groupId> <artifactId>MavenDemo</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <!-- spring start--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>4.1.6.RELEASE</version> </dependency> <!-- spring end--> <!-- mybatis start--> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.2.8</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.2</version> </dependency> <!-- mybatis end--> <!-- mysql connector start--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.34</version> </dependency> <!-- mysql connector end--> <!-- junit start--> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> </dependency> <!-- junit end--> <!-- 阿里巴巴數據源包 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.0.2</version> </dependency> </dependencies> </project核心技術:Maven,Springmvc mybatis shiro, Druid, Restful, Dubbo, ZooKeeper,Redis,FastDFS,ActiveMQ,Nginx 1. 項目核心代碼結構截圖
項目模塊依賴
特別提醒:開發人員在開發的時候能夠將本身的業務REST服務化或者Dubbo服務化
2. 項目依賴介紹
2.1 後臺管理系統、Rest服務系統、Scheculer定時調度系統依賴以下圖:
2.2 Dubbo獨立服務項目依賴以下圖:
3. 項目功能部分截圖:
zookeeper、dubbo服務啓動
dubbo管控臺
REST服務平臺