方法一:直接把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分支:1 个月前 )
83a38634 When using flatten-maven-plugin with updatePomFile=true and parent expansion, Maven incorrectly detected a parent cycle during the install phase. The error occurred because the consumer POM builder was using Path instead of ModelSource when reading the flattened POM. This change updates the PomArtifactTransformer API to use ModelSource instead of Path. ModelSource includes the necessary context (base directory, ModelLocator) to properly resolve parent POMs and avoid false cycle detection. Changes: - Updated PomArtifactTransformer.transform() to accept ModelSource instead of Path - Modified ConsumerPomArtifactTransformer to create ModelSource with proper resolution context - Updated DefaultConsumerPomBuilder and related classes to work with ModelSource - Added integration test to verify the fix Fixes #11399 (cherry picked from commit 5ec059c2d75393aaada2d2c1d0fe0100a1f79554) 1 天前
3411fd2f 1 天前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐