使用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项目文件 ...
随机推荐
- SpringBoot使用Redis数据库
(1)pom.xml文件引入jar包,如下: <dependency> <groupId>org.springframework.boot</groupId> &l ...
- 安装 bochs-x
sudo apt-get install bochs-x
- 【C#笔札】Tryparse的用法
这是参考读物的上得一个例子.自己仿照做的作业 private void button1_Click(object sender, EventArgs e) { int P_int_Number,i; ...
- Jbuilder(3300✨)
https://github.com/rails/jbuilder Jbuilder(3300✨) Jbuilder gives you a simple DSL for declaring JSON ...
- Python环境管理--virtualenvwrapper
遇到问题: 当最近的开发和部署过程中,多个服务器部署的时候发现对于库和包的管理非常混乱,主要有俩个版本问题: 因为业务需要,代码得分别部署在不同的服务器上面,每次部署的时候都得重复的安装包而且不能确定 ...
- 2018HN多校
http://acm.hi-54.com/contest_problemset.php?cid=1455 A : 摩斯密码 概览问题列表状态排名 Progress Bar 时间限制:1 Sec 内存限 ...
- 001——数组(一)数组知识及foreach函数应用
<?php /**数组(一)数组知识及foreach函数应用*/ /*数组:在一个变量中,存储一个或多个值,每一个元素都有一个访问ID * * */ /* * //索引型数组 $arr=arra ...
- js获取当前日期加上30天之后的日期
var date1 = new Date(); var date2 = new Date(date1); date2.setDate(date1.getDate() + 30); console.lo ...
- 我的octopress配置
在github上用octopress搭建了自己的blog,octopress号称是"专门给黑客打造的博客(A blogging framework for 把hackers)",使 ...
- java回收finalize方法的作用(编程思想)
清理:终结处理和垃圾回收 java有垃圾回收期负责回收无用对象占据的内存资源.但也有这种情况:假定你的对象(并非使用new)获得了一块“特殊”的内存区域,由于垃圾回收期只知道释放那些由new分配的内存 ...