方法一:直接把jar包复制到maven中所部属的目录下

方法二:用mvn install 命令配,  命令例子如下:

mvn install:install-file-Dfile=D:\maven-jar\HsviewClient-2.0.jar -DgroupId=com.hsview.client-DartifactId=HsviewClient -Dversion=2.0 -Dpackaging=jar

说明:  -Dfile 就是你下载的jar包的位置   -DgroupId 就是pom里对应的groupId   DartifactId 也是pom里对应的DartifactId,也是jar包名字(-符号前面的部分),

-Dversion 就是jar包的版本(- 符号后面的部分 )   -Dpackaging=jar

使用以上两种方法都没有解决问题。

使用第三种方法解决问题:

1、首先我在项目根目录中创建一个lib文件夹,将jar包拷贝到lib文件夹下 
   
2、然后我们在maven的pom.xml中配置
<dependency> 
<groupId>cn.sportsdata.secutil</groupId>  
<artifactId>secutil</artifactId>  
<version>0.0.1</version>  
<scope>system</scope>  
<systemPath>${project.basedir}/lib/secutil-0.0.1.jar  
</systemPath>
</dependency>
3、这里的groupId和artifactId以及version都是可以随便填写的 ,scope必须填写为system,而systemPath我们现在我们jar包的地址就可以了
4、最后我们必须在maven打包的过程中加入我们这个jar包。因为项目运行的时候需要这个Jar,并且我们得拷贝在WEB-INF/lib目录
 <build>

<plugins> 
<plugin>
<groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                    <webResources>
                        <resource>
                            <directory>${project.basedir}/lib</directory>
                            <targetPath>WEB-INF/lib</targetPath>
                            <filtering>false</filtering>
                            <includes>
                                <include>**/*.jar</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
                <version>2.1.1</version>
</plugin>

</plugins>

  </build>

GitHub 加速计划 / ma / maven
36
2
下载
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
最近提交(Master分支:2 个月前 )
f93b5629 Bumps [net.sourceforge.pmd:pmd-core](https://github.com/pmd/pmd) from 7.18.0 to 7.19.0. - [Release notes](https://github.com/pmd/pmd/releases) - [Commits](https://github.com/pmd/pmd/compare/pmd_releases/7.18.0...pmd_releases/7.19.0) --- updated-dependencies: - dependency-name: net.sourceforge.pmd:pmd-core dependency-version: 7.19.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 1 天前
25c80d8e Co-authored-by: TheRealHaui <michael.hausegger@hausegger.tech> 4 天前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐