Maven 如何像 Gradle 一样添加本地依赖库

使用 Gradle 构建可以这样导入整个编译依赖

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar']) // 像是这样

    compile('io.socket:socket.io-client:0.7.0') {

        exclude group: 'org.json', module: 'json'

    }

    compile 'com.android.support:appcompat-v7:23.2.0'

    compile 'com.android.support:recyclerview-v7:23.2.0'

    compile 'com.android.support:design:23.2.0'

    compile 'com.google.android.gms:play-services-appindexing:8.1.0'


    testCompile 'junit:junit:4.12'

}

但是找遍了 Maven 的插件,只有添加单个 jar

 <dependencies>

    <dependency>

      <groupId>org.x</groupId>

      <artifactId>my-jar</artifactId>

      <version>1.0</version>

      <scope>system</scope>

      <systemPath>${project.basedir}/lib/x.jar</systemPath>

    </dependency>

  </dependencies>

另外使用添加 classpath 的方法也没用,编译的时候还是出错

<plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-surefire-plugin</artifactId>

                <version>2.19.1</version>

                <configuration>

                    <additionalClasspathElements>

                        <classpathElement>${project.basedir}/src/main/webapp/WEB-INF/lib</classpathElement>

                    </additionalClasspathElements>

                </configuration>

            </plugin>

项目原本是 eclipse dynam web project


泛舟湖上清波郎朗
浏览 862回答 2
2回答

慕标5832272

添加单个Jar依赖&nbsp; &nbsp;&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>alipay</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>alipay</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>4.0</version>&nbsp; &nbsp; &nbsp; &nbsp; <scope>system</scope>&nbsp; &nbsp; &nbsp; &nbsp; <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/alipay-sdk-java.jar</systemPath>&nbsp; &nbsp; </dependency>${basedir}为项目根目录
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java