Maven引入第三方jar包到问题处理

Maven项目引入第三方jar包到问题处理

    • 背景:
    • 1. 下载jar包,通过maven命令手动安装到本地maven仓库
    • 2. jar放到项目路径下,通过pom直接引用

背景:

开发中会遇到需要使用第三方依赖的时,第三方依赖在中央仓库没有,解决方法

1. 下载jar包,通过maven命令手动安装到本地maven仓库

mvn install:install-file -DgroupId=com.aspose -DartifactId=aspose-words -Dversion=18.2.0 -Dpackaging=jar -Dfile=aspose-words-18.2.0-jdk16.jar
 
-DgroupId:pom.xml中groupId
-DartifactId:pom.xml中artifactId
-Dversion:pom.xml中0.0.1-SNAPSHOT
-Dpackaging:jar或war,包的后缀名
-Dfile:包的本地真实地址,需要在jar所在的目录下执行该命令,否则会找不到

pom


        <dependency>
            <groupId>com.asposegroupId>
            <artifactId>aspose-wordsartifactId>
            <version>18.2version>
        dependency>

2. jar放到项目路径下,通过pom直接引用

 <dependency>
    <groupId>com.asposegroupId>
    <artifactId>aspose-wordsartifactId>
    <version>18.2version>
    <scope>systemscope>
    <systemPath>${project.basedir}/src/main/resources/lib/aspose-words-18.2-jdk16.jarsystemPath>
dependency>

systemPath:指定了引用jar包所在的位置,${project.basedir}指定是在当前项目下。

linux环境下还需要做如下配置

  <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
                <configuration>
                    
                    <skip>falseskip>
                configuration>
            plugin>
        plugins>
      	 
        <resources>
            <resource>
                <directory>src/main/javadirectory>
                <includes>
                    <include>**/*include>
                includes>
            resource>
            <resource>
                <directory>src/main/resourcesdirectory>
                <includes>
                    <include>**/*include>
                includes>
            resource>
            <resource>
                <directory>src/main/resourcesdirectory>
                <targetPath>BOOT-INF/targetPath>
                <includes>
                    <include>/lib/*.jarinclude>
                includes>
            resource>
        resources>
    build>

你可能感兴趣的:(jar,pycharm,java,maven)