maven的pom文件

 pom.xml打jar包时加入依赖的包:

<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.scenery</groupId>
  <artifactId>DataService</artifactId>
  <version>1.0</version>
  <packaging>jar</packaging>

  <name>DataService</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  
<repositories>
    <repository>
        <id>central</id>
        <url>http://repo.corp/artifactory/repo</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>
    
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
		<groupId>jdom</groupId>
		<artifactId>jdom</artifactId>
		<version>1.1</version>
	</dependency>
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>5.1.13</version>
		<scope>runtime</scope>
	</dependency>
  </dependencies>
  
 <build>
    <plugins>
      <plugin>
        <!-- NOTE: We don't need a groupId specification because the group is
             org.apache.maven.plugins ...which is assumed by default.
         -->
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
		</plugin>
	</plugins>
</build>
</project>

maven命令:

1. mvn clean install

2. mvn assembly:assembly

即可生成包含依赖jar的jar包。

你可能感兴趣的:(maven)