GitHub地址:https://github.com/UncleClover/clover-springboot.git
工具环境:eclipse、JDK1.7、gradle
目录结构:
build.gradle配置文件内容:
buildscript {
ext {
springBootVersion = '1.4.7.RELEASE'
}
repositories {
// mavenCentral()
maven { url "http://127.0.0.1:8082/nexus/content/groups/public/"}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.7
repositories {
mavenCentral()
}
sourceSets{
main{
java{srcDirs = ["src/main/java"]}
resources{srcDirs = ["src/main/resources"]}
}
test{
java{srcDirs=['src/main/test']}
resources{srcDirs=['src/main/resources']}
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
spring boot入口类:SpringbootApplication
启动SpringbootApplication类,使用的spring boot内嵌的Tomcat8
package com.clover.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* spring boot 程序入口
*
* @author zhangdq
* @time 2018年3月1日 上午11:22:50
* @Email qiang900714@126.com
*/
@SpringBootApplication
public class SpringbootApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
}
spring boot控制类:HelloController
package com.clover.springboot.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* srpingboot测试类
*
* @author zhangdq
* @time 2018年3月1日 上午11:04:10
* @Email qiang900714@126.com
*/
@RestController
public class HelloController {
@GetMapping("/hello")
public String index() {
System.out.println("==================测试方法=====================");
return "helloworld";
}
}