Maven环境搭建、调试、打包
2024-09-04 14:56:16
1、配置Maven环境
将下载文件解压,然后设置maven环境
新建环境变量M2_HOME
变量名:M2_HOME
变量值:F:\maven\apache-maven-3.0.3
追加path环境变量
找到path其变量值尾部加入:;%M2_HOME%\bin;---前面注意分号
2、修改仓库位置
我的仓库路径:F:\maven\repo----这个路径是我自己创建,你可以将路径创建在任何位置。
我们打开…\apache-maven-3.0.3\conf\目录下的setting.xml文件,设置成我们创建的仓库路径
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository-->
<localRepository>F:\maven\m2\repository</localRepository>
3、导入eclipse开发工具
先配置maven仓库路径
Window----Perferences-----java-----Build Path-----Classpath Variables
New一个变量的类路径。
注:如果已有该变量则修改如下图:
4、Eclipse中添加jetty-plugin(用于调试运行)
1)、在pom.xml中添加如下配置
......<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.5</version>
<configuration>
<webAppSourceDirectory>src/main/webapp</webAppSourceDirectory>
<scanIntervalSeconds>3</scanIntervalSeconds>
<contextPath>/payment</contextPath>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8088</port>
</connector>
</connectors>
</configuration>
</plugin>
</plugins>
2)、Eclipse中配置Run Configurations
5、maven项目打包
1)、pom.xml文件中添加配置
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<warFile>target/payment.war</warFile>
</configuration>
</plugin>
<!-- 打包到远程 -->
<!-- <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId>
<configuration> <url>http://远程地址/payment</url> <server>test</server> <path>/</path>
</configuration> </plugin> -->
2)、执行打包
命令窗口到你的project目录执行命令:mvn package
最新文章
- 4.Powershell交互界面
- linux shell脚本使用结构化命令(2)
- PCI在linux系统中注册与注销示例
- Asp.Net Web API 2第十八课——Working with Entity Relations in OData
- ADB not responding. If you&#39;d like to retry, then please manually kill ";adb.exe"; and click &#39;Restart&#39;
- Redis数据库?-Redis的Virtual Memory介绍(转)
- 【.NET】单例模式标准写法
- busybox filesystem ifup
- leetcode_question_112 Path Sum
- AngularJs(一) MVC 模式的应用
- javascript面向对象创建高级 Web 应用程序
- Codeforces 442B Andrey and Problem(贪婪)
- WCF(三)分布式事务
- Centos7通过SSH使用密钥实现免密登录
- linux 安装 ftp 实现文件共享
- 安装Docker和配置加速器(二)
- 自动化CodeReview - ASP.NET Core依赖注入
- PNG文件格式详解
- 解决UITableView上的cell的重用
- hexo搭建