【vscode】使用vscode搭建gradle+springboot工程

1. 安装相应的插件

安装以下插件:

  • Java Extension Pack
  • Debugger for Java
  • Gradle Extension Pack
  • Gradle Language Support
  • Lombok Annotations Support for VS Code
  • Spring Boot Extension Pack
  • Spring Initializr Java Support
  • Eclipse Keymap

2. 创建gradle工程

  • 使用Ctrl+Shift+P,然后在弹出框中输入spring,然后在弹出的下拉中选择创建gradle工程;
  • 然后依次选择语言为Java,group Id:com.seven, artifact Id: vscode01,版本:2.2.6,以及其他部分信息,然后等待下载zip包到本地;

3. 修改配置,将仓库修改为阿里仓库

修改后内容如下:

buildscript {
    repositories {
        mavenLocal()
        maven {
            url "http://maven.aliyun.com/nexus/content/groups/public"
//            credentials {
//                username "${mavenUser}"
//                password "${mavenPwd}"
//            }
        }
    }
}
plugins {
	id 'org.springframework.boot' version '2.2.6.RELEASE'
	id 'io.spring.dependency-management' version '1.0.9.RELEASE'
	id 'java'
}

group = 'com.seven'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

configurations {
	developmentOnly
	runtimeClasspath {
		extendsFrom developmentOnly
	}
	compileOnly {
		extendsFrom annotationProcessor
	}
}

repositories {
    mavenLocal()
    maven {
        url "http://maven.aliyun.com/nexus/content/groups/public"
//            credentials {
//                username "${mavenUser}"
//                password "${mavenPwd}"
//            }
    }
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter'
	compileOnly 'org.projectlombok:lombok'
	developmentOnly 'org.springframework.boot:spring-boot-devtools'
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation('org.springframework.boot:spring-boot-starter-test') {
		exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
	}

	compile "org.springframework.boot:spring-boot-starter-web"
}

test {
	useJUnitPlatform()
}

4. 运行

在DemoApplication中点击Run,然后运行。

你可能感兴趣的:(#)