Maven多模块项目,适用于一些比较大的项目,通过合理的模块拆分,实现代码的复用,便于维护和管理。尤其是一些开源框架,也是采用多模块的方式,提供插件集成,用户可以根据需要配置指定的模块。
项目结构如下:
test-hd-parent (父级) ---pom.xml ---test-hd-api (第三方接口层) ----pom.xml ---test-hd-foundation (基础工具层) ----pom.xml ---test-hd-resource (资源层) ----pom.xml ---test-hd-service (逻辑业务层) ----pom.xml ---test-hd-modules (web层) ----pom.xml ---test-hd-piler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> <finalName>test-hd-www</finalName> </build></project>最后使用maven-update整个工程,右击父工程名--》Maven--》Update Project
打包和发布
打包,右击父工程名 test-hd-parent---->Run As--->Maven Install
打包web子工程,右击工程名test-hd-www--->Run As ---> Maven Build...---> Goals: clean package--->Run
右击工程名test-hd-www,进行刷新,找到war包,放到tomcat的webapps中,启动tomcat,即可访问工程http://localhost:8080/test-hd-www
可以去tomcat下面webapps》test-hd-www》WEB-INF》lib中,看到引用的jar包
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。