javamall.manager.web是一个聚合工程的子模块,它的父工程是javamall.manager。阅读此篇文章,建议大家先看本站的这篇文章:Java购物商城系统后台管理系统的架构。
下面就是新建javamall.manager.web模块的过程。
第一步:
选中“javamall.manager”右键,依次单击“New”→“Module”。
第二步
在这一步,就和之前的新建pojo、mapper、service不一样了,因为这个是web项目,所以我们需要勾选“Create from archetype”,并且选中下面的“org.apache.maven.archetypes:maven-archetype-webapp”。
然后单击“Next”。
第三步
可以,看到,该模块的Parent(父工程)就是javamall.manager。
填写ArtifactId,内容是:javamall.manager.web。然后单击“Next”
第四步
这步是maven的一些自定义配置,默认即可,我们单击“Next”。
第五步
修改Module name为:javamall.manager.web,默认是javamallmanagerweb,我习惯加个“.”来分隔。
第六步:修改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/xsd/maven-4.0.0.xsd"> <parent> <artifactId>javamall.manager</artifactId> <groupId>com.codingwhy</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>javamall.manager.web</artifactId> <packaging>war</packaging> <name>javamall.manager.web Maven Webapp</name> <!-- FIXME change it to the project's website --> <url>http://www.codingwhy.com</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <dependency> <groupId>com.codingwhy</groupId> <artifactId>javamall.manager.service</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <!-- Mybatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> </dependency> <!-- MySql --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!-- 连接池 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> </dependency> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> </dependency> <!-- 文件上传组件 --> <!-- 没有会报错 --> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> </dependency> <!-- 没有会报406 --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> </dependency> </dependencies> <build> <finalName>javamall.manager.web</finalName> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.1.0</version> </plugin> <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>3.2.2</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> </plugins> </pluginManagement> </build> </project>
关于pom的修改,以及依赖关系,可以看下我之前的这张图片
最后,看下web模块,新建成功后的截图吧。