欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

maven常用的依赖配置,tomcat和jetty双配置

程序员文章站 2022-06-10 21:37:50
...
<?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>com.lrlz</groupId>
  <artifactId>lrlz-platform</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>

  <repositories>
		<repository>
			<id>nexus-releases</id>
			<name>Local Nexus Repository</name>
			<url>http://oa.lrlz.com:8081/nexus/content/repositories/releases</url>
		</repository>

		<repository>
			<id>thirdparty</id>
			<name>Local Nexus Repository</name>
			<url>http://********/nexus/content/repositories/thirdparty</url>
		</repository>
	</repositories>
	<distributionManagement>
		<repository>
			<id>nexus-releases</id>
			<name>Local Nexus Repository</name>
			<url>http://********/nexus/content/repositories/releases</url>
		</repository>
		<snapshotRepository>
			<id>nexus-snapshots</id>
			<name>Local Nexus Repository</name>
			<url>http://********/nexus/content/repositories/snapshots</url>
		</snapshotRepository>
	</distributionManagement>

	<!-- 设置 Spring 的版本信息-->
	<properties>
		<jdk.version>1.7</jdk.version>
		<org.springframework.version>4.0.0.RELEASE</org.springframework.version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<dependencies>
		<!-- Core utilities used by other modules. Define this if you use Spring 
			Utility APIs (org.springframework.core.*/org.springframework.util.*) -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${org.springframework.version}</version>
			 <exclusions>
				 <exclusion>
					 <groupId>commons-logging</groupId>
					 <artifactId>commons-logging</artifactId>
				 </exclusion>
			 </exclusions>
		</dependency>

		<!-- Expression Language (depends on spring-core) Define this if you use 
			Spring Expression APIs (org.springframework.expression.*) -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-expression</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>

		<!-- Bean Factory and JavaBeans utilities (depends on spring-core) Define 
			this if you use Spring Bean APIs (org.springframework.beans.*) -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>

		<!-- Aspect Oriented Programming (AOP) Framework (depends on spring-core, 
			spring-beans) Define this if you use Spring AOP APIs (org.springframework.aop.*) -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aop</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>

		<!-- Application Context (depends on spring-core, spring-expression, spring-aop, 
			spring-beans) This is the central artifact for Spring's Dependency Injection 
			Container and is generally always defined -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>

		<!-- Various Application Context utilities, including EhCache, JavaMail, 
			Quartz, and Freemarker integration Define this if you need any of these integrations -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context-support</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>

		<!-- Transaction Management Abstraction (depends on spring-core, spring-beans, 
			spring-aop, spring-context) Define this if you use Spring Transactions or 
			DAO Exception Hierarchy (org.springframework.transaction.*/org.springframework.dao.*) -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>

		<!-- JDBC Data Access Library (depends on spring-core, spring-beans, spring-context, 
			spring-tx) Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*) -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>

		<!-- Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA, 
			and iBatis. (depends on spring-core, spring-beans, spring-context, spring-tx) 
			Define this if you need ORM (org.springframework.orm.*) -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-orm</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>

		<!-- Object-to-XML Mapping (OXM) abstraction and integration with JAXB, 
			JiBX, Castor, XStream, and XML Beans. (depends on spring-core, spring-beans, 
			spring-context) Define this if you need OXM (org.springframework.oxm.*) <dependency> 
			<groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> 
			<version>${org.springframework.version}</version> </dependency> -->

		<!-- Web application development utilities applicable to both Servlet and 
			Portlet Environments (depends on spring-core, spring-beans, spring-context) 
			Define this if you use Spring MVC, or wish to use Struts, JSF, or another 
			web framework with Spring (org.springframework.web.*) -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>

		<!-- Spring MVC for Servlet Environments (depends on spring-core, spring-beans, 
			spring-context, spring-web) Define this if you use Spring MVC with a Servlet 
			Container such as Apache Tomcat (org.springframework.web.servlet.*) -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>

		<!-- Spring MVC for Portlet Environments (depends on spring-core, spring-beans, 
			spring-context, spring-web) Define this if you use Spring MVC with a Portlet 
			<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc-portlet</artifactId> 
			<version>${org.springframework.version}</version> </dependency> Container 
			(org.springframework.web.portlet.*) -->

		<!-- Support for testing Spring applications with tools such as JUnit and 
			TestNG This artifact is generally always defined with a 'test' scope for 
			the integration testing framework and unit testing stubs -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>${org.springframework.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aspects</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jms</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.9</version>
			<scope>test</scope>
		</dependency>


		<!-- 上面的都是Spring的jar包,可以选择性的添加 -->

		<!-- Mybatis -->
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis-spring</artifactId>
			<version>1.2.1</version>
		</dependency>

		<!-- Mybatis 和Spring整合包,是mybatis出的 -->
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
			<version>3.2.3</version>
		</dependency>

		<!-- oracle的数据库驱动
		<dependency>
			<groupId>com.oracle</groupId>
			<artifactId>oracle14</artifactId>
			<version>10.2.0.4.0</version>
		</dependency> -->
		
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.34</version>
		</dependency>
		
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
			<version>1.0.15</version>
		</dependency>

		<!-- oro -->
		<dependency>
			<groupId>oro</groupId>
			<artifactId>oro</artifactId>
			<version>2.0.8</version>
		</dependency>

		<!-- 日志打印 log4j -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>1.7.5</version>
		</dependency>
		<!-- druid 是配置数据源的包 
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
			<version>1.0.1</version>
		</dependency>
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
			<version>1.1.36</version>
		</dependency>-->


		<!-- Spring 文件上传的包 -->
		<dependency>
			<groupId>commons-fileupload</groupId>
			<artifactId>commons-fileupload</artifactId>
			<version>1.3</version>
		</dependency>
		<!-- Spring 文件上传的依赖包 -->
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>2.4</version>
		</dependency>
		<!-- 基本工具Jar -->
		<dependency>
			<groupId>commons-beanutils</groupId>
			<artifactId>commons-beanutils</artifactId>
			<version>1.9.0</version>
			<exclusions>
				<exclusion>
					<groupId>commons-logging</groupId>
					<artifactId>commons-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>commons-collections</groupId>
			<artifactId>commons-collections</artifactId>
			<version>3.2.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<version>3.2</version>
		</dependency>
		<dependency>
			<groupId>commons-configuration</groupId>
			<artifactId>commons-configuration</artifactId>
			<version>1.10</version>
		</dependency>

		<!-- <dependency>
			<groupId>commons-dbutils</groupId>
			<artifactId>commons-dbutils</artifactId>
			<version>1.5</version>
		</dependency> -->

		<!-- dom4j 解析 XML文件的包 -->
		<dependency>
			<groupId>dom4j</groupId>
			<artifactId>dom4j</artifactId>
			<version>1.6.1</version>
		</dependency>

		<dependency>
			<groupId>jaxen</groupId>
			<artifactId>jaxen</artifactId>
			<version>1.1.4</version>
		</dependency>

		<!-- 下面的三个包是在配置事务的时候用到的 spring的依赖包 -->
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjweaver</artifactId>
			<version>1.7.4</version>
		</dependency>
		<dependency>
			<groupId>aopalliance</groupId>
			<artifactId>aopalliance</artifactId>
			<version>1.0</version>
		</dependency>
		<dependency>
			<groupId>cglib</groupId>
			<artifactId>cglib-nodep</artifactId>
			<version>3.1</version>
		</dependency>
		<dependency>
			<groupId>com.google.guava</groupId>
			<artifactId>guava</artifactId>
			<version>15.0</version>
		</dependency>
		<dependency>
			<groupId>joda-time</groupId>
			<artifactId>joda-time</artifactId>
			<version>2.3</version>
		</dependency>
		<!-- 下面的两个包是jedis的依赖包 -->
		<dependency>  
            <groupId>redis.clients</groupId>  
            <artifactId>jedis</artifactId>  
            <version>2.1.0</version>  
        </dependency>  
		<dependency>  
           <groupId>org.springframework.data</groupId>  
           <artifactId>spring-data-redis</artifactId>  
           <version>1.0.2.RELEASE</version>  
        </dependency>
        
        <dependency>
		    <groupId>com.google.code.gson</groupId>
		    <artifactId>gson</artifactId>
		    <version>2.3.1</version>
		</dependency>
		
		<!-- ssh通信架包
		<dependency>
			<groupId>com.googlecode.xmemcached</groupId>
			<artifactId>xmemcached</artifactId>
			<version>1.3.5</version>
		</dependency> 
		<dependency>
			<groupId>sshtools</groupId>
			<artifactId>j2ssh-core</artifactId>
			<version>0.2.2</version>
		</dependency>-->
		
		<dependency>
			<groupId>taglibs</groupId>
			<artifactId>standard</artifactId>
			<version>1.1.2</version>
		</dependency>
		<dependency>
			<groupId>xstream</groupId>
			<artifactId>xstream</artifactId>
			<version>1.4.4</version>
		</dependency>
		<dependency>
			<groupId>xml-apis</groupId>
			<artifactId>xml-apis</artifactId>
			<version>1.4.01</version>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<version>4.3.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpmime</artifactId>
			<version>4.2.1</version>
		</dependency>
		<dependency>
			<groupId>org.freemarker</groupId>
			<artifactId>freemarker</artifactId>
			<version>2.3.20</version>
		</dependency>

		<!-- netty 
		<dependency>
			<groupId>org.jboss.netty</groupId>
			<artifactId>netty</artifactId>
			<version>3.2.5.Final</version>
		</dependency>
		<dependency>
			<groupId>org.apache.activemq</groupId>
			<artifactId>activemq-all</artifactId>
			<version>5.5.0</version>
		</dependency>-->

		<dependency>
			<groupId>net.sf.json-lib</groupId>
			<artifactId>json-lib</artifactId>
			<version>2.4</version>
			<classifier>jdk15</classifier>
		</dependency>
		
		<!-- 处理json -->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-core</artifactId>
			<version>2.0.0</version>
		</dependency>
		<dependency>
			<groupId>org.codehaus.jackson</groupId>
			<artifactId>jackson-mapper-asl</artifactId>
			<version>1.9.5</version>
		</dependency>
		<dependency>
			<groupId>org.codehaus.jackson</groupId>
			<artifactId>jackson-core-asl</artifactId>
			<version>1.9.5</version>
		</dependency> 
		
		<dependency>
			<groupId>com.belerweb</groupId>
			<artifactId>pinyin4j</artifactId>
			<version>2.5.0</version>
		</dependency>
		
	<!-- 	<dependency>
		    <groupId>org.apache.struts</groupId>
		    <artifactId>struts2-json-plugin</artifactId>
		    <version>2.3.16.3</version>
		</dependency> -->
		
		<!-- mongodb依赖包
	    <dependency>
		  <groupId>org.apache.lucene</groupId>
		  <artifactId>lucene-core</artifactId>
		  <version>3.5.0</version>
		</dependency>
		<dependency>
		  <groupId>org.apache.lucene</groupId>
		  <artifactId>lucene-highlighter</artifactId>
		  <version>3.5.0</version>
		</dependency>
		<dependency>
			<groupId>org.mongodb</groupId>
			<artifactId>mongo-java-driver</artifactId>
			<version>2.11.3</version>
		</dependency>-->
		
		<dependency>
			  <groupId>fakepath</groupId>
			  <artifactId>quartz-all</artifactId>
			  <version>1.6.1</version>
		</dependency>
		
		<!-- jetty -->
		<dependency>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>servlet-api-2.5</artifactId>
			<version>6.1.14</version>
			<scope>provided</scope>
		</dependency>
		
	</dependencies>
	<build>
		<finalName>${project.artifactId}</finalName>

		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>${jdk.version}</source>
					<target>${jdk.version}</target>
				</configuration>
		    </plugin>
		</plugins>
		
		<resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>com/lrlz/**/sqlmap/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource> 
        </resources>

	</build>
	
	<!-- 聚合 -->
	<modules>
		<module>core</module>
	    <module>system</module>
	    <module>buyer</module>
	    <module>webApp</module>
	</modules>
</project>

 

以上是父工程的pom.xml文件,

在子工程中把jetty加入进来如下:

 

<build>
      <finalName>webApp</finalName>
      <plugins>
		  <plugin>  
			  <groupId>org.eclipse.jetty</groupId>  
			  <artifactId>jetty-maven-plugin</artifactId>  
			  <version>9.2.2.v20140723</version>  
			    <configuration>  
			    <scanIntervalSeconds>10</scanIntervalSeconds>  
			  </configuration>  
		  </plugin> 

	   </plugins>
  </build>

 一定要注意jetty的版本问题,jdk是1.7以上,jetty对应的要选9以上,这个为问题困扰了我一天多

 

这样配置后本地环境既可以通过tomcat发布,也可以通过jetty来发布

 

jetty发布的命令:jetty:run -Djetty.port=8888

tomcat发布的命令:tomcat:run -Dmaven.tomcat.port=8080 -Dmaven.tomcat.path=/