web项目pom.xml基本配置

resources目录各环境配置:
env目录:

  • local.properties 本地环境
  • dev.properties 开发环境
  • test.properties 测试环境
  • www.properties 生产环境

pom.xml基本内容如下(基于spring-cloud):

<?xml version="1.0"?>
<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>
	<parent>
		<groupId>cn.xxx</groupId>
		<artifactId>xxx-cloud</artifactId>
		<version>0.0.2</version>
	</parent>
	<artifactId>xxx-user-service</artifactId>
	<version>0.0.3-SNAPSHOT</version>
	<packaging>war</packaging>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<!--默认本地环境-->
		<package.environment>local</package.environment>
		<!--忽略文档打包错误-->
		<maven.javadoc.failOnError>false</maven.javadoc.failOnError>
	</properties>
	<profiles>
		<profile>
			<id>local</id>
			<properties>
				<package.environment>local</package.environment>
			</properties>
		</profile>
		<profile>
			<id>dev</id>
			<properties>
				<package.environment>dev</package.environment>
			</properties>
		</profile>
		<profile>
			<id>test</id>
			<properties>
				<package.environment>test</package.environment>
			</properties>
		</profile>
		<profile>
			<id>www</id>
			<properties>
				<package.environment>www</package.environment>
			</properties>
		</profile>
	</profiles>

	<dependencies>
		<dependency>
			<groupId>cn.xxx</groupId>
			<artifactId>xxx-common-core</artifactId>
			<version>0.0.5</version>
		</dependency>
		<dependency>
			<groupId>cn.xxx</groupId>
			<artifactId>xxx-cms-model</artifactId>
			<version>0.0.2</version>
		</dependency>
		<dependency>
			<groupId>cn.xxx</groupId>
			<artifactId>xxx-user-model</artifactId>
			<version>0.0.3</version>
		</dependency>
		<dependency>
			<groupId>cn.xxx</groupId>
			<artifactId>xxx-sct-model</artifactId>
			<version>0.0.2</version>
		</dependency>
		<dependency>
			<groupId>cn.xxx</groupId>
			<artifactId>xxx-common-cache</artifactId>
			<version>0.0.2</version>
		</dependency>
		<dependency>
			<groupId>cn.xxx</groupId>
			<artifactId>xxx-base-models</artifactId>
			<version>0.0.2</version>
		</dependency>
		<dependency>
			<groupId>cn.xxx</groupId>
			<artifactId>xxx-common-file</artifactId>
			<version>0.0.3</version>
		</dependency>
		<dependency>
			<groupId>cn.xxx</groupId>
			<artifactId>xxx-base-service</artifactId>
			<version>0.0.2</version>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.google.zxing</groupId>
			<artifactId>core</artifactId>
			<version>3.3.0</version>
		</dependency>
		<dependency>
			<groupId>commons-collections</groupId>
			<artifactId>commons-collections</artifactId>
		</dependency>
		<dependency>
			<groupId>commons-lang</groupId>
			<artifactId>commons-lang</artifactId>
		</dependency>
		<dependency>
			<groupId>org.jsoup</groupId>
			<artifactId>jsoup</artifactId>
		</dependency>
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
		</dependency>
		<dependency>
			<groupId>dom4j</groupId>
			<artifactId>dom4j</artifactId>
		</dependency>
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
		</dependency>
		<dependency>
			<groupId>commons-fileupload</groupId>
			<artifactId>commons-fileupload</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpmime</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-eureka</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-feign</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<!-- 移除嵌入式tomcat插件 -->
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-tomcat</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>
		<!-- springboot end -->
		<!-- test -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpmime</artifactId>
			<scope>test</scope>
		</dependency>
    </dependencies>
	<build>
		<resources>
			<resource>
				<directory>${basedir}/src/main/resources</directory>
				<filtering>true</filtering>
				<excludes>
					<exclude>env/*.*</exclude>
				</excludes>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
				<configuration>
					<detail>true</detail>
					<includeEmptyDirs>true</includeEmptyDirs>
					<overwrite>true</overwrite>
					<encoding>UTF-8</encoding>
					<filters>
						<filter>${basedir}/src/main/resources/env/${package.environment}.properties</filter>
					</filters>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<skip>true</skip>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-release-plugin</artifactId>
				<version>2.5.3</version>
				<configuration>
					<providerImplementations>
						<git>jgit</git>
					</providerImplementations>
					<!--git账号,用于将版本打成tag-->
					<username>xxx</username>
					<!--git密码-->
					<password>xxx</password>
					<tagBase>${project.artifactId}-${project.version}</tagBase>
					<!-- war不发布到nexus上了 -->
					<goals>-f pom.xml package</goals>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>org.apache.maven.scm</groupId>
						<artifactId>maven-scm-provider-jgit</artifactId>
						<version>1.9.5</version>
					</dependency>
				</dependencies>
			</plugin>
		</plugins>
	</build>
	<scm>
		<connection>scm:git:http://git.xxx.net/xxx-cloud/xxx-user-service.git</connection>
		<developerConnection>scm:git:http://git.xxx.net/xxx-cloud/xxx-user-service.git</developerConnection>
		<url>http://git.xxx.net/xxx-cloud/xxx-user-service/tree/master</url>
		<tag>HEAD</tag>
	</scm>
</project>

打生产war包
git pull
mvn release:prepare
如失败:mvn release:rollback
mvn release:perform
如失败,重新执行该命令。

打包生产环境:
mvn clean package -Pwww

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SSM项目的pom.xml配置文件主要包含以下内容: 1. 项目依赖:SSM项目依赖于Spring、Spring MVC和MyBatis,因此需要在pom.xml文件中添加它们的依赖。 2. 数据库驱动:如果使用了数据库,需要在pom.xml文件中添加对应的数据库驱动依赖。 3. Maven插件:SSM项目需要使用Maven构建,因此需要在pom.xml文件中添加相应的Maven插件。 以下是一个简单的SSM项目pom.xml配置示例: ``` <dependencies> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>5.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.2.5.RELEASE</version> </dependency> <!-- Spring MVC --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.2.5.RELEASE</version> </dependency> <!-- MyBatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.4</version> </dependency> <!-- MySQL JDBC driver --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.20</version> </dependency> </dependencies> <build> <plugins> <!-- Maven编译插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <!-- Maven打包插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.2.0</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>com.example.Main</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> ``` 注意:以上示例仅供参考,实际的pom.xml文件可能因项目需求而有所不同。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值