工欲善其事必先利其器
1,gradle安装
1.1 下载https://services.gradle.org/distributions/
解压到一个目录:
1.2配置环境变量
GRADLE_USER_HOME:D:\soft\gradle-6.1.1\repo
同样配置:GRADLE_HOME:D:\soft\gradle-6.1.1
追加path:D:\soft\gradle-6.1.1\bin
1.3验证:gradle -v
1.4简单说明下gradle工程和maven中的pom相对应的两个重要文件
解释build.gradle和settings.gradle
settings.gradle是用来管理多项目的,里面包含了项目的name
build.gradle:,
plugins是应用的插件
dependencies是用于声明这个项目依赖于哪些jar
测试编译阶段我们依赖junit的jar。其中包括complile(编译时)runtime(运行时)testCompile(测试编译时)testRuntime(测试运行时)。
repositories是一个仓库gradle会根据从上到下的顺序依次去仓库中寻找jar
默认的是一个maven的中心仓库,其中mavenLocal()表示使用本地maven仓库;mavenCentral()使用maven中心仓库。使用固定的地址,这里可以使用阿里云(maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'})的镜像下载速度会快一些,然后也可以使用公司内部的私服地址
一个spring boot的gradle配置文件例子
一个例子:
plugins {
id 'org.springframework.boot' version '2.3.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
id 'war'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
//mavenCentral()
maven {
url "http://maven.aliyun.com/nexus/content/groups/public/"
}
}
dependencies {
compile 'log4j:log4j:1.2.17'
compile 'org.slf4j:slf4j-api:1.7.7'
testCompile group: 'junit', name: 'junit', version: '4.13'
compile 'org.springframework:spring-core'
implementation 'org.springframework.boot:spring-boot-starter-freemarker'
implementation 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.3'
runtimeOnly 'mysql:mysql-connector-java'
runtimeOnly 'org.postgresql:postgresql'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation('org.springframework.boot:spring-boot-starter-test'
) {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
2,eclipse配置
help->Ecllipse Marketplace
配置:
windows->preference
3,eclipse安装spring boot插件
4,svn插件安装
5,安装源码插件Java Source Attacher
之前安装的很多链接都失效了,以下是在线安装步骤:
打开地址https://marketplace.eclipse.org/marketplace-client-intro?mpc_install=84997,将会出现一个Install按钮
大概意思就是直接拖动到你的Eclipse工作空间即可;其实也就是安装一个插件到ecllipse目录中
6,智能提示
java的自动提示,点击“windows”->"preferences",弹出preferences设置窗口,展开列表"Editor"->"Content Assist",点击Content Assist后,把下列字母串粘贴到红框里面:.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
XML,依次展开列表"XML Files"->"Editor"->"Content Assist",点击Content Assist后,
下列字母串粘贴到里面:
<=:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789