If ruoyi imports the local jar according to the framework, it cannot be packaged into the solution

Table of contents

1. Problems

2. Error resolution ideas

3. Real solutions

Summarize


1. Problems

Ruoyi separates the front-end and back-end frameworks. The project needs to introduce local jar packages, but maven cannot package them when packaging them.

problem code

system模块pom.xml文件引用


<dependency>
            <groupId>com.usign</groupId>
            <artifactId>usign-util</artifactId>
            <version>1.1</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/usign-util-1.1.jar</systemPath>
        </dependency>

 At this time, it is normal to start debugging locally, but when maven package is installed, the local jar package is not entered.

2. Error resolution ideas

system的pom.xml加入了以下代码

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <compilerArguments>
                        <extdirs>${project.basedir}/lib/usign-util-1.1.jar</extdirs>
                    </compilerArguments>
                </configuration>
            </plugin>
        </plugins>
    </build>

When maven package, the local jar package is not typed in, and the online solution is useless, throwing should not point at files within the project directory ... warning.

Baidu, everyone's solution is this

移除本地包依赖中的 <scope/> 和 <systemPath/>
<dependency>
  <groupId>ppts.model</groupId>
  <artifactId>ppts-model</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>
通过 maven-install-plugin 插件对 jar 包进行安装
<phase>clean</phase> 表示该 jar 包会在执行 clean 操作时引入
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-install-plugin</artifactId>
  <version>2.5.2</version>
  <executions>
    <execution>
      <id>install-ppts-model</id>
      <phase>clean</phase>
      <configuration>
        <file>${basedir}/../lib/ppts-model-1.0-SNAPSHOT.jar</file>
        <repositoryLayout>default</repositoryLayout>
        <groupId>ppts.model</groupId>
        <artifactId>ppts-model</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
        <generatePom>true</generatePom>
      </configuration>
      <goals>
        <goal>install-file</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Please see clearly that there must be a problem with this code. First remove <scope/> and <systemPath/> in the local package dependencies, and the local reference will definitely report an error. . . . . Too bad.

3. Real solutions

1.system模块下建lib把jar文件放进去

2.system模块pom.xml文件引用


<dependency>
            <groupId>com.usign</groupId>
            <artifactId>usign-util</artifactId>
            <version>1.1</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/usign-util-1.1.jar</systemPath>
        </dependency>

3.admin 模块pom.xml build configuration标签下加上:

<includeSystemScope>true</includeSystemScope>

完整代码:

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.1.1.RELEASE</version>
                <configuration>
                    <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>   
                <groupId>org.apache.maven.plugins</groupId>   
                <artifactId>maven-war-plugin</artifactId>   
                <version>3.1.0</version>   
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <warName>${project.artifactId}</warName>
                </configuration>   
           </plugin>   
        </plugins>
        <finalName>${project.artifactId}</finalName>
    </build>

 

Summarize

Don't trust all the tutorials on the Internet, including this one. To persuade everyone to try it out when posting articles, most of them are other people's tutorial methods that have not been verified and plagiarized. . . .

Guess you like

Origin blog.csdn.net/xieedeni/article/details/125394531