300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > Maven构建多模块web项目(IDEA)

Maven构建多模块web项目(IDEA)

时间:2020-06-15 20:41:55

相关推荐

Maven构建多模块web项目(IDEA)

title: Maven构建多模块web项目(IDEA)

项目结构

dangmanager => 父模块 manager_common => 公共模块(如工具类)manager_pojo => 实体模型模块manager_dao => 持久层模块manager_dao => 持久层模块manager_service => 服务层模块manager_controller => 控制层模块(配置文件所在)

构建项目

构建父模块 new - > project构建各个模块new - > module

需要关联某个模块时加入:

<dependency><artifactId>Utils</artifactId><groupId>com.liu**.mvn3</groupId><version>1.0-SNAPSHOT</version></dependency>

clean和install各个模块

注意:首先clean和install父模块;然后先clean和install没有依赖的模块,再clean和install有依赖的模块(其依赖的模块必须先进行clean和 install,否则会依赖管理打包faild);两个模块不能相互加入依赖模块坐标,会报循环调用错误。(有相互依赖的情况下将两个模块合并写成一个模块)

(当install一个模块,maven发现模块内依赖其他模块jar,maven会在本地仓库中寻找该jar,找不到自然会报错。install作用就是将模块打包成jar记录在本地仓库供依赖模块使用)

使用Maven Tomcat Plugin运行web项目

在父模块pom加入

<!-- 多模块运行插件 --><build><plugins><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><version>2.2</version><configuration><port>7090</port><path>/</path></configuration></plugin></plugins></build>

运行clean tomcat7:run

注意

父模块打包方式为pom,子模块(无子模块)打包方式为jar, controller打包方式为war;

未完

我的博客

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。