如何在基于 Maven 的项目 Java 中安装 MWS 库?
How to work install MWS library in Java, Maven based project?
这是我第一次尝试将 MWS 库与 Java
一起使用。我有小型 Spring Boot
应用 Maven
型。我想从我想使用的 https://mvnrepository.com/ by mws
I found several libraries located on Fishbowldev
. At the time of writing this post, repo seems to be unavailable. Example of library 安装 mws
。
目前,我的 pom.xml
看起来是这样的:
<?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>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.test.api</groupId>
<artifactId>test-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>test-api</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<repositories>
<repository>
<id>fishbowldev</id>
<name>Fishbowldev Repository</name>
<url>http://murky.fishbowldev.com:8081/nexus/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- MWS libraries -->
<!-- https://mvnrepository.com/artifact/amazon/mws-client -->
<dependency>
<groupId>amazon</groupId>
<artifactId>mws-client</artifactId>
<version>1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/amazon/mws-sellers -->
<dependency>
<groupId>amazon</groupId>
<artifactId>mws-sellers</artifactId>
<version>2011-07-01</version>
</dependency>
<!-- https://mvnrepository.com/artifact/amazon/mws-orders -->
<dependency>
<groupId>amazon</groupId>
<artifactId>mws-orders</artifactId>
<version>2013-09-01-2015-09-25</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
除了手动安装之外,还有其他方法可以将此库添加到我的 pom.xml
文件中吗?
我没有为我的问题找到任何确切的解决方案。相反,我找到了一个解决方法。 Mavenised
旧 MWS Java SDK
在 GitHub 上的项目。
该解决方案不会创建任何使用 MWS
的奇特方式,它只是基于 Maven
的项目的方便包装。
第 1 步: 在 pom.xml
中配置目标 install-file
maven-install-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-external-non-maven-jar-MWS-Client-into-local-maven-repo</id>
<phase>clean</phase>
<configuration>
<repositoryLayout>default</repositoryLayout>
<groupId>com.amazonservices.mws</groupId>
<artifactId>mws-client</artifactId>
<version>1.0</version>
<file>${project.basedir}/lib/MWSClientJavaRuntime-1.0.jar</file>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
确保根据您的实际文件路径编辑 file
路径(建议将这些外部非 Maven jar 放在某个文件夹中,比方说 lib
,然后将此 lib
项目中的文件夹,以便使用项目特定的相对路径并避免添加系统特定的绝对路径。
第 2 步: 在 pom.xml
文件中如上所示配置 maven-install-plugin
后,您必须在 pom.xml
和往常一样:
<dependency>
<groupId>com.amazonservices.mws</groupId>
<artifactId>mws-client</artifactId>
<version>1.0</version>
</dependency>
请注意,maven-install-plugin
仅将外部 jar 复制到本地 .m2
maven 存储库。而已。它不会自动将这些 jar 作为 Maven 依赖项包含到您的项目中。
这是一个小问题,但有时很容易被忽略。
这是我第一次尝试将 MWS 库与 Java
一起使用。我有小型 Spring Boot
应用 Maven
型。我想从我想使用的 https://mvnrepository.com/ by mws
I found several libraries located on Fishbowldev
. At the time of writing this post, repo seems to be unavailable. Example of library 安装 mws
。
目前,我的 pom.xml
看起来是这样的:
<?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>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.test.api</groupId>
<artifactId>test-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>test-api</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<repositories>
<repository>
<id>fishbowldev</id>
<name>Fishbowldev Repository</name>
<url>http://murky.fishbowldev.com:8081/nexus/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- MWS libraries -->
<!-- https://mvnrepository.com/artifact/amazon/mws-client -->
<dependency>
<groupId>amazon</groupId>
<artifactId>mws-client</artifactId>
<version>1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/amazon/mws-sellers -->
<dependency>
<groupId>amazon</groupId>
<artifactId>mws-sellers</artifactId>
<version>2011-07-01</version>
</dependency>
<!-- https://mvnrepository.com/artifact/amazon/mws-orders -->
<dependency>
<groupId>amazon</groupId>
<artifactId>mws-orders</artifactId>
<version>2013-09-01-2015-09-25</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
除了手动安装之外,还有其他方法可以将此库添加到我的 pom.xml
文件中吗?
我没有为我的问题找到任何确切的解决方案。相反,我找到了一个解决方法。 Mavenised
旧 MWS Java SDK
在 GitHub 上的项目。
该解决方案不会创建任何使用 MWS
的奇特方式,它只是基于 Maven
的项目的方便包装。
第 1 步: 在 pom.xml
install-file
maven-install-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-external-non-maven-jar-MWS-Client-into-local-maven-repo</id>
<phase>clean</phase>
<configuration>
<repositoryLayout>default</repositoryLayout>
<groupId>com.amazonservices.mws</groupId>
<artifactId>mws-client</artifactId>
<version>1.0</version>
<file>${project.basedir}/lib/MWSClientJavaRuntime-1.0.jar</file>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
确保根据您的实际文件路径编辑 file
路径(建议将这些外部非 Maven jar 放在某个文件夹中,比方说 lib
,然后将此 lib
项目中的文件夹,以便使用项目特定的相对路径并避免添加系统特定的绝对路径。
第 2 步: 在 pom.xml
文件中如上所示配置 maven-install-plugin
后,您必须在 pom.xml
和往常一样:
<dependency>
<groupId>com.amazonservices.mws</groupId>
<artifactId>mws-client</artifactId>
<version>1.0</version>
</dependency>
请注意,maven-install-plugin
仅将外部 jar 复制到本地 .m2
maven 存储库。而已。它不会自动将这些 jar 作为 Maven 依赖项包含到您的项目中。
这是一个小问题,但有时很容易被忽略。