赞
踩
本次开发使用spring聚合工程,大概如下
common层:类似枚举类,工具类都放在该层
pojo层:项目实体类
mapper(dao)层:数据库操作
server层:逻辑
api层:接口
新建父项目,既parent框架,拿我手头项目为例:
父项目在选择打包方式时,要选择pom而不是war或者jar
panshi-studio为整体parent
parent/pom.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>cn.jxau</groupId>
- <artifactId>panshi-studio</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>pom</packaging>
- <build/>
- <name>磐石工作室微信小程序</name>
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>1.5.12.RELEASE</version>
- <relativePath/>
- </parent>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <java.version>1.8</java.version>
- </properties>
-
- <modules>
- <module>common</module>
- <module>panshi-studio-common</module>
- <module>panshi-studio-pojo</module>
- <module>panshi-studio-dao</module>
- <module>panshi-studio-service</module>
- <module>panshi-studio-api</module>
- </modules>
- </project>
基本就是设置spring boot版本 编码格式 还有一些模块信息
common/pom.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>
- <parent>
- <groupId>cn.jxau</groupId>
- <artifactId>panshi-studio</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>panshi-studio-common</artifactId>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter</artifactId>
- <exclusions>
- <!-- 排除springboot默认的logback日志框架 -->
- <exclusion>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- 引入log4j日志依赖 -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-log4j</artifactId>
- <version>1.3.8.RELEASE</version>
- </dependency>
-
- <!-- 引入spring aop依赖 -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-aop</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- <exclusions>
- </exclusions>
- </dependency>
-
- <!-- 资源配置 -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-configuration-processor</artifactId>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-thymeleaf</artifactId>
- </dependency>
-
- <!-- 阿里开源数据源 -->
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>druid</artifactId>
- <version>1.1.0</version>
- </dependency>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>druid-spring-boot-starter</artifactId>
- <version>1.1.0</version>
- </dependency>
-
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.41</version>
- </dependency>
-
- <!-- mybatis -->
- <dependency>
- <groupId>org.mybatis.spring.boot</groupId>
- <artifactId>mybatis-spring-boot-starter</artifactId>
- <version>1.3.1</version>
- </dependency>
- <!--mapper -->
- <dependency>
- <groupId>tk.mybatis</groupId>
- <artifactId>mapper-spring-boot-starter</artifactId>
- <version>1.2.4</version>
- </dependency>
- <!--pagehelper -->
- <dependency>
- <groupId>com.github.pagehelper</groupId>
- <artifactId>pagehelper-spring-boot-starter</artifactId>
- <version>1.2.3</version>
- </dependency>
-
- <!-- apache 工具类 -->
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>1.11</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.3.2</version>
- </dependency>
-
- <!-- swagger2 配置 -->
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger2</artifactId>
- <version>2.4.0</version>
- </dependency>
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger-ui</artifactId>
- <version>2.4.0</version>
- </dependency>
-
- <!-- 引入 redis 依赖 -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-redis</artifactId>
- </dependency>
- <dependency>
- <groupId>redis.clients</groupId>
- <artifactId>jedis</artifactId>
- <version>2.9.0</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.data</groupId>
- <artifactId>spring-data-redis</artifactId>
- <version>1.8.7.RELEASE</version>
- </dependency>
- </dependencies>
- </project>
项目所用的的所有依赖都在common这一层中写出,因为后面各个模块都会依赖common所以后面不用写这些了。
右键parent,选择新建maven module
next,填写模块名称,finish:
找到新建模块的pom.xml,双击,操作如下图
next:在输入框中填写所要依赖的模块名,在结果中选择想要的,点击ok:
一个模块就完成了,创建和依赖
pojo/pom.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>
- <parent>
- <groupId>cn.jxau</groupId>
- <artifactId>panshi-studio</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>panshi-studio-pojo</artifactId>
- <build/>
- <dependencies>
- <dependency>
- <groupId>cn.jxau</groupId>
- <artifactId>panshi-studio-common</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </project>
mapper(dao)/pom.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>
- <parent>
- <groupId>cn.jxau</groupId>
- <artifactId>panshi-studio</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>panshi-studio-dao</artifactId>
- <build/>
- <dependencies>
- <dependency>
- <groupId>cn.jxau</groupId>
- <artifactId>panshi-studio-pojo</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </project>
service/pom.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>
- <parent>
- <groupId>cn.jxau</groupId>
- <artifactId>panshi-studio</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>panshi-studio-service</artifactId>
- <build/>
- <dependencies>
- <dependency>
- <groupId>cn.jxau</groupId>
- <artifactId>panshi-studio-dao</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </project>
api/pom.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>
- <parent>
- <groupId>cn.jxau</groupId>
- <artifactId>panshi-studio</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>panshi-studio-api</artifactId>
- <build/>
- <dependencies>
- <dependency>
- <groupId>cn.jxau</groupId>
- <artifactId>panshi-studio-service</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </project>
这样一个spring boot聚合工程就大致完成了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。