使用maven构建基本的web项目结构
由于当前公司在组织进行项目基本结构的整理,将以前通过eclipse/ ant 方式构建的项目向maven上迁移,于是便进行maven项目方面的调研。
对于maven项目,基本的结构已经在标准文件中:
<!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->
| src/main/java | Application/Library sources |
| src/main/resources | Application/Library resources |
| src/main/filters | Resource filter files |
| src/main/webapp | Web application sources |
| src/test/java | Test sources |
| src/test/resources | Test resources |
| src/test/filters | Test resource filter files |
| src/it | Integration Tests (primarily for plugins) |
| src/assembly | Assembly descriptors |
| src/site | Site |
| LICENSE.txt | Project's license |
| NOTICE.txt | Notices and attributions required by libraries that the project depends on |
| README.txt | Project's readme |
由于我们使用git作为版本管理工具,在使用maven作为build工具时,需要将IDE的工程描述文件以及项目生成的target/,bin/目录忽略掉,因此.gitignore文件必不可少,以下内容可以作为项目的.gitignore文件范本: # generated files where run in local machine
bin/
target/ # eclipse project description files
.settings/
.project # idea project description files
.idea/
*.iml ### Java template
*.class # Mobile Tools for Java (J2ME)
.mtj.tmp/ # Package Files #
*.jar
*.war
*.ear # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

<profiles>
<profile>
<id>dev</id>
<properties>
<active.profile>dev</active.profile>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile> <profile>
<id>test</id>
<properties>
<active.profile>test</active.profile>
</properties>
</profile> <profile>
<id>product</id>
<properties>
<active.profile>product</active.profile>
</properties>
</profile>
</profiles>

<build>
<finalName>example</finalName>
<filters>
<filter>src/main/filters/filters-${active.profile}.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
- filters-dev.properties
- filters-test.properties
- filters-product.properties
dbc.url=${pom.jdbc.url}
jdbc.username=${pom.jdbc.username}
jdbc.passworkd=${pom.jdbc.password}
pom.jdbc.url=dev
pom.jdbc.username=dev
pom.jdbc.password=dev
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src/main/resource</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>conf/**</exclude>
</excludes>
</resource>
<resource>
<directory>package/${package.environment}</directory>
<filtering>true</filtering>
</resource>
</resources>
<profiles>
<profile>
<id>dev</id>
<properties>
<package.environment>dev</package.environment>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<package.environment>test</package.environment>
</properties>
</profile>
</profiles>

<repository>
<id>mvnrepository</id>
<name>mvnrepository</name>
<url>http://www.mvnrepository.com</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->
-U,--update-snapshots Forces a check for missing
releases and updated snapshots on
remote repositories
使用maven构建基本的web项目结构的更多相关文章
- 图文详解 IntelliJ IDEA 15 创建 Maven 构建的 Java Web 项目(使用 Jetty 容器)
图文详解 IntelliJ IDEA 15 创建 maven 的 Web 项目 搭建 maven 项目结构 1.使用 IntelliJ IDEA 15 新建一个项目. 2.设置 GAV 坐标 3. ...
- 图文具体解释 IntelliJ IDEA 15 创建 Maven 构建的 Java Web 项目(使用 Jetty 容器)
图文具体解释 IntelliJ IDEA 15 创建 maven 的 Web 项目 搭建 maven 项目结构 1.使用 IntelliJ IDEA 15 新建一个项目. 2.设置 GAV 坐标 3. ...
- maven构建简单的web项目
把jdk给换掉 项目修改好了以后写个页面测试一下,结果正常 下面应该添加依赖让web项目一步步丰满起来. 0-添加依赖 1-建一个servlet 2-web.xml中添加servlet声明 3-重新运 ...
- 使用maven构建第一个web项目
在eclipse中,正常创建maven项目后,发现在index.jsp中会报错,此时在pom.xml中加入如下依赖关系即可 <dependency> <groupId>java ...
- Eclipse中使用Maven创建Servlet3.0 Web 项目
摘要 Apache Maven是一个优秀的项目构建和管理工具,许多开源项目都使用Maven进行构建.由于最近工作中要用到Maven,于是这里记录下在Eclipse中使用Maven插件创建一个基于Ser ...
- Maven实现项目构建直接部署Web项目到Tomcat
Maven实现项目构建直接部署Web项目到Tomcat配置如下: 1.Tomcat的用户及权限配置:在conf目录下,找到tomcat-users.xml,添加manager权限的用户. <ro ...
- 使用Maven构建RichFaces 4.x项目
使用Maven构建RichFaces 4.x项目 目录 开始之前 第一步 - 创建Maven项目 第二布 - 添加依赖文件 第三步 - 配置RichFaces 第四步 - 创建显示页面 开始之前 本文 ...
- Maven构建真正的J2EE项目
今天同事问起我眼下用Maven构建的多模块项目架构和曾经用Eclipse创建的Web项目的问题.以下将讲一下使用maven搭建多模块的J2ee项目,以及採用这样的方式搭建项目对日后项目的水平拆分和垂直 ...
- 使用Apache Tomcat Maven插件部署运行 Web 项目
什么是Apache Tomcat Maven Plugin? Maven Plugin 是Apache Tomcat 提供的一个Maven插件,它可以在你没有tomcat容器时将任何一个war项目文件 ...
随机推荐
- UVa 10294 项链和手镯(polya)
https://vjudge.net/problem/UVA-10294 题意: 手镯可以翻转,但项链不可以.输入n和t,输出用t种颜色的n颗珠子能制作成的项链和手镯的个数. 思路: 经典等价类计数问 ...
- CentOS6.4x86EngCustomize120g__20160307.rar
安装的镜像包: CentOS-6.4-i386-bin-DVD1to2(CentOS-6.4-i386-bin-DVD1.iso / CentOS-6.4-i386-bin-DVD2.iso) 1. ...
- githubpage+hexo构建自己的个人博客
就这有这么一天,我感觉博客园的博客页面实在太low了.完全跟不上现在潮流. https://segmentfault.com/a/1190000004947261 http://coolcao.com ...
- 最小生成树prim和kruskal模板
prim: int cost[MAX_V][MAX_V]; //cost[u][v]表示边e=(u,v)的权值(不存在的情况下设为INF) int mincost[MAX_V]; //从集合X出发的每 ...
- python3 中文乱码,UnicodeEncodeError: 'latin-1' codec can't encode characters in position 10-13: ordinal not in range(256)
将其源代码复制下来运行之后,报了下面这个错误: UnicodeEncodeError: 'latin-1' codec can't encode characters in position 9-13 ...
- Alpha阶段第1周 Scrum立会报告+燃尽图 02
作业要求与https://edu.cnblogs.com/campus/nenu/2018fall/homework/2246相同 一.小组介绍 组长:刘莹莹 组员:朱珅莹 孙韦男 祝玮琦 王玉潘 周 ...
- PCB 中过孔和通孔焊盘的区别
在PCB设计中,过孔VIA和焊盘PAD都可以实现相似的功能.它们都能插入元件管脚,特别是对于直插DIP)封装的的器件来说,几乎是一样的. 但是!在PCB制造中,它们的处理方法是不一样的. 1.VIA的 ...
- Cause: org.postgresql.util.PSQLException: ERROR: cached plan must not change result type的前因后果
首先说明一下遇到的问题: PG数据库,对其中的某张表增加一列后,应用报错,信息如下: 应用使用相关框架如下:SpringBoot.MyBatis. ### Cause: org.postgresql. ...
- 接口测试Fiddler实战20150921
(写好的文章被不小心删掉了,现在补一篇) 项目背景: 1.接口URL:http://192.168.xx.xx:8080/mserver/rest/ms 2.接口参数:data=xxxxx&k ...
- Linux运维学习笔记-网络安全等级保护
网络安全等级保护简介与作用: 验证信息系统是否满足相应安全保护等级的一个过程. 对不同信息系统分等级进行保护.