找回remove了 Maven Dependencies

配置Eclipse Maven项目

在项目的根路径下找到.classpath文件,在classpath节点下面添加如下内容,然后刷新项目即可。

<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
	<attributes>
		<attribute name="maven.pomderived" value="true"/>
		<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
	</attributes>
</classpathentry>


`maven.aliyun.com` 是阿里巴巴提供的 Maven 镜像仓库,常用于加速 Maven 和 Gradle 依赖的下载。你可能是想使用阿里云的 Maven 镜像来加速 Gradle 构建过程。 --- ## ✅ 使用阿里云 Maven 镜像加速 Gradle 构建 你可以通过修改 `build.gradle` 或 `gradle.properties` 文件来使用阿里云的 Maven 镜像,从而加快依赖下载速度。 --- ### ✅ 方法一:在 `build.gradle` 中配置阿里云镜像 在 `build.gradle` 文件中添加以下内容: ```groovy repositories { maven { url 'https://maven.aliyun.com/repository/public' } mavenCentral() jcenter() } ``` > ⚠️ 注意:`jcenter()` 已经停止服务,建议移除或替换为 `mavenCentral()`。 --- ### ✅ 方法二:在 `gradle.properties` 中设置全局镜像 编辑 `gradle.properties` 文件(通常在项目根目录下),添加以下内容: ```properties # 使用阿里云作为 Maven 镜像 systemProp.http.proxyHost=mirrors.aliyun.com systemProp.http.proxyPort=80 systemProp.https.proxyHost=mirrors.aliyun.com systemProp.https.proxyPort=80 ``` > ✅ 此方法适用于全局依赖下载,适用于所有 `mavenCentral()`、`jcenter()` 等仓库。 --- ### ✅ 方法三:创建 `init.gradle` 设置全局镜像(推荐) 你可以创建一个全局的 `init.gradle` 文件,让所有项目都使用阿里云镜像。 #### 步骤: 1. 在用户目录下创建或编辑文件: - Windows: `C:\Users\<你的用户名>\.gradle\init.gradle` - macOS / Linux: `~/.gradle/init.gradle` 2. 添加以下内容: ```groovy allprojects { repositories { // 移除默认仓库 removeAll { it.name in ['M2', 'mavenCentral', 'jcenter', 'google', 'gradlePluginPortal'] } // 添加阿里云镜像 maven { url 'https://maven.aliyun.com/repository/public' } mavenCentral() jcenter() maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } } } ``` --- ## 🧪 示例:完整 `build.gradle` 配置(适用于 Forge 项目) ```groovy buildscript { repositories { maven { url = 'https://maven.aliyun.com/repository/public' } mavenCentral() } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.+' // 使用最新稳定版 } } apply plugin: 'net.minecraftforge.gradle' // 应用 ForgeGradle 插件 repositories { maven { url = 'https://maven.aliyun.com/repository/public' } mavenCentral() } ``` --- ## ✅ 效果 配置完成后,运行: ```bash ./gradlew --refresh-dependencies build ``` Gradle 会优先从阿里云镜像下载依赖,速度会显著提升。 --- ##
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值