项目构建步骤
1、File->New->Project
勾选Create from archetype
点击Next
2、输入GroupId、ArtifactId
点击Next
3、继续点击Next,输入Project name
点击Finish,完成基本项目创建
4、在src/main下添加java目录作为源文件目录
在main上右键new Directory并命名为java;
同时在Project Structure中,将java目录设置为Sources,然后Apply,点击OK。
5、配置pom.xml
可以在maven仓库进行相关依赖搜索:http://www.mvnrepository.com/
利用<dependency>元素进行项目所依赖的jar包配置,maven通过对pom.xml的配置使得不再需要导入jar包那么麻烦
6、配置tomcat
7、资源文件编译时一起打包到输出目录
IDEA的maven项目中,默认源代码目录下的xml等资源文件并不会在编译的时候一块打包进classes文件夹,而是直接舍弃掉。
项目中可能包含一些静态资源如: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目录如下,配置的静态资源文件被包含进来了
MavenDemo简单实例
1、项目结构
注: 在WEB-INFO/lib下存放有jstl.jar和standard.jar,需要将其导入项目的Libraries中(一般使用Maven不这样做,直接在pom.xml里面配置响应的jar包依赖就行,当时自动填补依赖有些问题故采取比较麻烦的方式做)
如图:
2、pom.xml配置
<?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服务平台



