在Eclipse使用Maven自动打包部署到服务器上
maven
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
项目地址:https://gitcode.com/gh_mirrors/ma/maven
·
在Eclipse上使用Maven实现自动部署
1. 准备工作:在eclipse上集成Maven
2. 首先是配置Tomcat conf 目录下的tomcat-users.xml,配置用户权限,提供给本地Maven使用
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
3. 登陆http://127.0.0.1/manager/text
成功登陆后就说明Tomcat权限已经配置好了,接下来就是本地Maven的配置了。
4.接下来是Maven里面的settings.xml文件的配置的<servers>中添加代码如下:
<server>
<id>test</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
注意:这里的id对应的是Maven项目 pom.xml里面的 server , 其他的username 和 password都是一致的,即 Tomcat登录的用户名和密码。
5.pom.xml的配置,在项目的build标签中添加3Maven个插件
1.maven-resources-plugin----xml/properties资源处理
2. maven-compiler-plugin---编译
3. tomcat7-maven-plugin---部署
<build>
<finalName>server-monitoring</finalName>
<resources>
<!-- 配置文件 -->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- 配置Tomcat插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8080</port>
<path>/server-monitoring</path>
<!-- 填写远程服务器地址 -->
<url>http://192.168.163.137:8080/manager/text</url>
<server>test</server>
<username>tomcat</username>
<password>tomcat</password>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
6.项目右键maven build….
设置goals:clean install tomcat7:depeloy
注意:如果是相互依赖的项目,先install 被依赖的项目
完成啦!!!!!!!!!!!!!!!!!!!!!
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
最近提交(Master分支:3 个月前 )
92a8fcb7
Bumps [org.codehaus.mojo:exec-maven-plugin](https://github.com/mojohaus/exec-maven-plugin) from 3.6.2 to 3.6.3.
- [Release notes](https://github.com/mojohaus/exec-maven-plugin/releases)
- [Commits](https://github.com/mojohaus/exec-maven-plugin/compare/3.6.2...3.6.3)
---
updated-dependencies:
- dependency-name: org.codehaus.mojo:exec-maven-plugin
dependency-version: 3.6.3
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com> 1 天前
2474702f
Bumps [org.codehaus.mojo:buildnumber-maven-plugin](https://github.com/mojohaus/buildnumber-maven-plugin) from 3.2.1 to 3.3.0.
- [Release notes](https://github.com/mojohaus/buildnumber-maven-plugin/releases)
- [Commits](https://github.com/mojohaus/buildnumber-maven-plugin/compare/3.2.1...buildnumber-maven-plugin-3.3.0)
---
updated-dependencies:
- dependency-name: org.codehaus.mojo:buildnumber-maven-plugin
dependency-version: 3.3.0
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 2 天前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)