It's the first time I am trying to use MWS library with Java
. I have small Spring Boot
application Maven
-based. I wanted to install mws
from 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 I wanted to use.
At the moment, my pom.xml
looks the following way:
<?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>
Is there any other way except of manual installation to add this library to my pom.xml
file?
Step 1: Configure the maven-install-plugin
with the goal install-file
in your pom.xml
<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>
Make sure to edit the file
path based on your actual file path (recommended is to place these external non-maven jars inside some folder, let's say lib
, and place this lib
folder inside your project so as to use project-specific relative path and avoid adding system specific absolute path.
Step 2: Once you have configured the maven-install-plugin
as shown above in your pom.xml
file, you have to use these jars in your pom.xml
as usual:
<dependency>
<groupId>com.amazonservices.mws</groupId>
<artifactId>mws-client</artifactId>
<version>1.0</version>
</dependency>
Note that the maven-install-plugin
only copies your external jars to your local .m2
maven repository. That's it. It doesn't automatically include these jars as maven dependencies to your project.
It's a minor point, but sometimes easy to miss.
I didn't find any exact solution for my question. Instead I found a workaround. The project that Mavenised
the old MWS Java SDK
on GitHub .
The solution doesn't create any fancy way of working with MWS
it is just a convenient wrapper for Maven
-based projects.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.