Maven Projects Setup
来源:互联网 发布:妇科专家在线网络咨询 编辑:程序博客网 时间:2024/06/08 15:51
You can create project by maven. But basically, we don’t prefer to do it. We always use Eclipse/IntelliJ to create maven project.
After creating project by maven project template in IntelliJ, we got below folder.
MyWebApp
|–.idea
|–src
|—-main
|—-resources
|–test
|–pom.xml
By default, we only have one setting named as “POM.xml”. It includes all core information related to project building/dependencies/basic artefact information.
Initialize 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"> <modelVersion>4.0.0</modelVersion> <groupId>myApp</groupId> <artifactId>myApp</artifactId> <version>1.0-SNAPSHOT</version></project>
Based on these initial settings, you can install package through maven clean install command.
Maven Build Process:
–validate: validate the project is correct and all necessary information is available
–compile: compile the source code of the project
–test: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
–package: take the compiled code and package it in its distributable format, such as a JAR.
–integration-test: process and deploy the package if necessary into an environment where integration tests can be run
–verify: run any checks to verify the package is valid and meets quality criteria
–install: install the package into the local repository, for use as a dependency in other projects locally
–deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
However, we want to add some dependencies and repositories. Given that, we need to modify pom.xml & add another setting file named as “Settings.xml”.
There are two settings.
POM.xml:
(1) We want to add JUNIT dependency. Given that, we add below settings.
<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency></dependencies>
(2) We want to add one plug-in when building projects, so that we add these settings.
<build> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.2.11.v20150529</version> <configuration> <webApp> <contextPath>/MyWebApp</contextPath> </webApp> <httpConnector> <port>80</port> </httpConnector> </configuration> </plugin> </plugins> </build>
Settings.xml: This configuration manage the global level configuration information for all maven projects.
These include values such as the local repository location, alternate remote repository servers, and authentication information
We define local repository & remote repository.
<?xml version="1.0" encoding="UTF-8"?><settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>/Users/kangxiwei/maven</localRepository> <interactiveMode>true</interactiveMode> <usePluginRegistry>false</usePluginRegistry> <profiles> <profile> <id>profile-default</id> <repositories> <repository> <id>repo-mirror</id> <url>http://maven.net.cn/content/groups/public/</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>plugin-repo-mirror</id> <url>http://maven.net.cn/content/groups/public/</url> </pluginRepository> </pluginRepositories> </profile> </profiles></settings>
Related links:
Maven in 5 Minutes
Maven Getting Started
Maven Settings.xml
- Maven Projects Setup
- Getting Started With Setup Projects
- Releasing Maven projects to Github
- Simple Maven Workspace Setup
- Maven - Environment Setup
- How to setup and configure Sonar for Groovy projects
- Using Scala IDE on Maven projects
- 【spring】Building Java Projects with Maven
- eclipse importing maven projects 9% 不动
- IntelliJ Idea maven projects没了怎么办
- eclipse importing maven projects 卡顿
- Eclipse 3.6 Helios + Maven Setup
- Projects
- Intellij 如果让Maven projects 中显示maven plugins
- 导入一个maven工程后一直显示importing maven projects
- [转]How to setup ASP.NET v1.1 (Visual Studio .NET 2003) projects on IIS7 (Vista)
- Post-Build script to fix MSI issues in Vista for VS 2005 Setup and Deployment Projects
- Create custom dialogs for use in your Visual Studio Setup projects
- 深入理解Java内存模型——总结
- 伸缩自如的时光轴实现——改进版
- gcc
- arm常用汇编指令和伪指令
- 【sql server】存储过程扩展
- Maven Projects Setup
- Android 实现简单画板二
- 第二次作业(c语言)
- Git的常用命令
- Android图片的时分秒倒计时
- 绘制B样条曲线
- hdu 5412 CRB and Queries(动态求区间第k小+整体二分)
- javasavacript 递归优化,递归变while
- STL算法_基本算法篇