Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pom 文件引用本地 jar 的一点儿小建议 #281

Open
lixifun opened this issue Nov 18, 2022 · 0 comments
Open

pom 文件引用本地 jar 的一点儿小建议 #281

lixifun opened this issue Nov 18, 2022 · 0 comments

Comments

@lixifun
Copy link

lixifun commented Nov 18, 2022

pom 文件引用本地 jar 的一点儿小建议

pom 文件中引用本地 jar 包,可以不进行 install 操作,可以避免 污染 本地库?

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
  <execution>
      <id>install-taobao-sdk-auto</id>
      <phase>clean</phase>
      <configuration>
          <file>lib/taobao-sdk-java-auto.jar</file>
          <groupId>com.taobao</groupId>
          <artifactId>taobao-sdk-java-auto</artifactId>
          <version>1.0.0</version>
          <packaging>jar</packaging>
          <generatePom>true</generatePom>
      </configuration>
      <goals>
          <goal>install-file</goal>
      </goals>
  </execution>

在引用 本地 jar 包时,举例

<dependency>
      <groupId>com.taobao</groupId>
      <artifactId>taobao-sdk-java-auto</artifactId>
      <version>1.0.0</version>
      <scope>system</scope>
      <systemPath>${basedir}/lib/taobao-sdk-java-auto.jar</systemPath>
</dependency>

这样操作的话,需要将本地 jar 包所在的目录添加到 <resources> 标签中,这样打包也就会自动打进去了。

<build>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>lib</directory>
                <targetPath>libs</targetPath> <!--这行有没有不影响,只是为了打出来的 jar 里面的内容没那么乱 -->
            </resource>
        </resources>

</build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant