Eclipse+Gradle+springboot创建项目

一 Eclipse安装gradle插件

help-》Eclipsemarketplace->find中输入gradle->安装buildship gradle integration

二 搭建gradle项目

file->new->gradle(sts)
https://blog.csdn.net/qq133328114/article/details/65629744 详细步骤

三 配置gradle.build,集成springboot

apply plugin: 'eclipse'

buildscript {
	repositories {
		//mavenCentral()
		 maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
	}
	dependencies {
		classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.19.RELEASE'
	}
}


sourceCompatibility = 1.8
version = '1.0.0'
jar {
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart',
                   'Implementation-Version': version
    }
}

repositories {
	//mavenCentral()
	 maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}

dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    testCompile group: 'junit', name: 'junit', version: '4.+'
    compile: 'org.springframework.boot:spring-boot-starter-web'
	testCompile: 'org.springframework.boot:spring-boot-starter-test'
}

test {
    systemProperties 'property': 'value'
}

uploadArchives {
    repositories {
       flatDir {
           dirs 'repos'
       }
    }
}




四 创建springboot主配置类

创建Application.java文件,内容为


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController  
@EnableAutoConfiguration  
@SpringBootApplication 
public class Application {

    @RequestMapping("/")  
    String home() {  
        return "Hello World!";  
    }  

    public static void main(String[] args) {  
        SpringApplication.run(Application.class, args);  
    } 
}



你可能感兴趣的:(springboot)