本文主要是介绍分模块构建Maven工程(父工程maven_parent、子工程maven_pojo、子工程maven_dao、子工程maven_service、子工程maven_web、部署到tomcat),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、父工程maven_parent
不使用骨架,创建maven工程,名称为:maven_parent。
并在pom.xml中使用指定为父工程,锁定jar包版本,指定项目源码的jdk版本、编译后的jdk版本、以及编码。
<?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/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.lt</groupId><artifactId>maven_parent</artifactId><version>1.0-SNAPSHOT</version><!--父工程打包方式必须为pom--><packaging>pom</packaging><!--聚合其它maven工程--><modules><module>maven_pojo</module><module>maven_service</module><module>maven_dao</module><module>maven_web</module></modules><properties><spring.version>5.0.5.RELEASE</spring.version><springmvc.version>5.0.5.RELEASE</springmvc.version><mybatis.version>3.4.5</mybatis.version></properties><!--锁定jar包版本--><dependencyManagement><dependencies><!--三大框架之mybatis--><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>${mybatis.version}</version></dependency><!--三大框架之springMVC--><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>${springmvc.version}</version></dependency><!--三大框架之spring--><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aop</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-expression</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-web</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aspects</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context-support</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-tx</artifactId><version>${spring.version}</version></dependency></dependencies></dependencyManagement><build><plugins><plugin><!--使用maven-compiler-plugin插件可以指定项目源码的jdk版本,编译后的jdk版本,以及编码--><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.1</version><configuration><source>11</source><target>11</target><encoding>UTF-8</encoding></configuration></plugin></plugins></build>
</project>
二、子工程maven_pojo
不使用骨架,创建maven工程,名称为:maven_pojo。
* 创建时需要指定父工程
package com.lt.pojo;public class Account {private int id;private String name;private double money;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public double getMoney() {return money;}public void setMoney(double money) {this.money = money;}@Overridepublic String toString() {return "Account{"
这篇关于分模块构建Maven工程(父工程maven_parent、子工程maven_pojo、子工程maven_dao、子工程maven_service、子工程maven_web、部署到tomcat)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!