Open ghost opened 8 years ago
简单的说,每个通过Maven管理的Java工程都有一个pom.xml, 这个pom.xml里定义了你这个project 需要依赖的library name及version. Maven可以自动帮你到你配置文件里指定的url去下载这些library,无需你手动完成。
I have already told you that Maven is very important in our Java project.
Here below is a real pom.xml for Maven used in our project.
Please go through the content and try to understand the meaning of each xml tag.
<?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> <parent> <groupId>com.sap.cloud.yaas.service-sdk</groupId> <artifactId>service-sdk-superpom</artifactId> <version>4.3.4</version> <relativePath /> </parent> <groupId>com.sap.coil</groupId> <artifactId>OpeningEventDemo</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <properties> <!-- YaaS Service SDK Version --> <service-sdk.version>4.3.4</service-sdk.version> <!-- Library Versions --> <jaxrs.version>2.0.1</jaxrs.version> <jersey.version>2.19</jersey.version> <javax.servlet.version>3.1.0</javax.servlet.version> <spring.version>4.2.0.RELEASE</spring.version> <cors.filter.version>2.4</cors.filter.version> <!-- Test Library Versions --> <junit.version>4.12</junit.version> <!-- Plugin Versions --> <jetty.plugin.version>9.2.6.v20141205</jetty.plugin.version> <!-- Json Library Versions --> <json-lib.version>2.1</json-lib.version> </properties> <dependencies> <!-- YaaS Service SDK Dependencies --> <dependency> <groupId>com.sap.cloud.yaas.service-sdk</groupId> <artifactId>service-sdk-libraries</artifactId> <version>${service-sdk.version}</version> </dependency> <!-- Jersey Dependencies --> <dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> <version>${jaxrs.version}</version> </dependency> <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-servlet</artifactId> <version>${jersey.version}</version> </dependency> <dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-json-jackson</artifactId> <version>${jersey.version}</version> </dependency> <dependency> <groupId>org.glassfish.jersey.ext</groupId> <artifactId>jersey-spring3</artifactId> <version>${jersey.version}</version> </dependency> <dependency> <groupId>org.glassfish.jersey.ext</groupId> <artifactId>jersey-bean-validation</artifactId> <version>${jersey.version}</version> </dependency> <!-- Spring Dependencies --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <!-- Servlet Dependencies --> <dependency> <groupId>com.thetransactioncompany</groupId> <artifactId>cors-filter</artifactId> <version>${cors.filter.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>${javax.servlet.version}</version> <scope>provided</scope> </dependency> <!-- Testing Dependencies--> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.glassfish.jersey.test-framework.providers</groupId> <artifactId>jersey-test-framework-provider-grizzly2</artifactId> <version>${jersey.version}</version> <scope>test</scope> </dependency> <!-- Logging --> <dependency> <groupId>com.sap.cloud.yaas.service-sdk</groupId> <artifactId>service-sdk-logging</artifactId> <version>${service-sdk.version}</version> </dependency> <!-- Logging Filters--> <dependency> <groupId>com.sap.cloud.yaas.service-sdk</groupId> <artifactId>service-sdk-logging-filters</artifactId> <version>${service-sdk.version}</version> </dependency> <!-- Authorization --> <dependency> <groupId>com.sap.cloud.yaas.service-sdk</groupId> <artifactId>service-sdk-authorization</artifactId> <version>${service-sdk.version}</version> </dependency> <!-- Hystrix --> <dependency> <groupId>com.netflix.hystrix</groupId> <artifactId>hystrix-core</artifactId> <version>1.4.14</version> </dependency> <!-- JSON-Lib Dependencies--> <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>${json-lib.version}</version> <classifier>jdk15</classifier> </dependency> <!--Redis Support --> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.7.3</version> </dependency> </dependencies> <build> <finalName>OpeningEventDemo</finalName> <plugins> <!-- Plugin required to build API models and resources. This dependency should not be removed. --> <plugin> <groupId>com.sap.cloud.yaas.service-sdk</groupId> <artifactId>service-sdk-generator-maven-plugin</artifactId> <version>${service-sdk.version}</version> <executions> <execution> <goals> <goal>generate-service</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>${jetty.plugin.version}</version> <configuration> <scanIntervalSeconds>10</scanIntervalSeconds> <webApp> <contextPath>/</contextPath> </webApp> </configuration> </plugin> </plugins> <pluginManagement> <plugins> <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>com.sap.cloud.yaas.service-sdk</groupId> <artifactId>service-sdk-generator-maven-plugin</artifactId> <versionRange>[${service-sdk.version},)</versionRange> <goals> <goal>generate-service</goal> </goals> </pluginExecutionFilter> <action> <ignore /> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> </build> </project>
The version in pom.xml:
is mapped to library version here:
Another example:
2.19:
Overview
简单的说,每个通过Maven管理的Java工程都有一个pom.xml, 这个pom.xml里定义了你这个project 需要依赖的library name及version. Maven可以自动帮你到你配置文件里指定的url去下载这些library,无需你手动完成。
Detail
I have already told you that Maven is very important in our Java project.
Here below is a real pom.xml for Maven used in our project.
Action for you
Please go through the content and try to understand the meaning of each xml tag.
The version in pom.xml:
is mapped to library version here:
Another example:
2.19: