部署Halo遇到问题 gradle build下载依赖失败
用IntelliJ IDEA导入Halo一直失败,gardle build一直显示connection reset或者 Read timed out, 提示不能从https://plugins.gradle.org/m2/…下载spring-boot-core之类的。找了各种方法,build.gradle里的maven url换成aliyun的也不行。最后解决方法如下:
手动下载gradle
从gradle官网下载最新gradle安装包
解压压缩包,比如D:\gradle-6.2.2。
在 D:\gradle-6.2.2 目录下新建一个文件夹,名字为:.gradle
。注意:前面有个小点,这个文件夹是gradle
放置jar包的本地仓库,就像maven
也有个文件夹充当本地仓库一样。
在.gradle
文件夹里新建一个 init.gradle
文件,这一步是为了配置下载依赖的国内镜像,内容如下:
ext {
nexus = 'http://maven.aliyun.com/nexus/content/groups/public'
username = 'admin'
password = 'admin123'
}
allprojects{
repositories {
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/') || !url.startsWith(nexus)) {
project.logger.lifecycle "Repository ${repo.url} replaced by ${nexus}."
remove repo
}
}
}
maven {
url nexus
}
}
}
settingsEvaluated { settings ->
settings.pluginManagement {
resolutionStrategy {
}
repositories {
maven {
url nexus
}
}
}
}
配置环境变量
-
新建系统变量
-
在path中添加
%GRADLE_HOME%\bin
变量
开始搭建
克隆项目到本地https://github.com/halo-dev/halo.git
用idea打开项目
配置gradle
问题应该得到解决
之后可能提示lombok错误
在安装lombok
插件后如果提示...lombok...was not found in any of the following sources
将build.gradle
对应行注释掉即可
plugins {
id "org.springframework.boot" version "2.2.2.RELEASE"
// id "io.freefair.lombok" version "3.6.6" 把这行注释掉
id 'checkstyle'
id 'java'
}