Introduction: Due to project requirements, the interface of the SMS verification code needs to be replaced by Alibaba's greater than, but I was embarrassed to find that the jar package that Alibaba's greater than did not have the maven version, so I started the morning of fucking the bag. According to routine, it should naturally be Baidu's wave, but after Baidu found a lot of solutions, it was found that none of them were useful, and the plagiarism and copying of the article were very serious. After trying N solutions, they were all wrong. They did not package the external jar package into the BOOK-INF folder. Finally, after the Nth attempt, the external jar package was finally imported into the jar package. Let’s record it here to prevent re-offending! ! !
First, create a new libs folder (both in the root directory or resource directory), and put the jar you need to import into it.
Then add the following configuration to the pom, telling maven to import the local jar
<dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-core</artifactId> <version>3.2.2</version> <scope>system</scope> <systemPath>${project.basedir}/libs/aliyun-java-sdk-core-3.3.1.jar</systemPath> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-dysmsapi</artifactId> <version>1.0.0</version> <scope>system</scope> <systemPath>${project.basedir}/libs/aliyun-java-sdk-dysmsapi-1.0.0.jar</systemPath> </dependency>Except for the systemPath configuration tells the location of the local jar package introduced by maven, other configurations can be written casually.
Make a point! ! ! Knock on the blackboard! ! ! The following step is also the most important step. Many tutorials on the Internet lack such a step, and although it can be run locally, it cannot be used to package it with maven, because maven does not also make the local jar into the generated package.
Set the includeSystemScope parameter for the spring boot packaging plugin in pom
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> </plugin> </plugins></build>
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.