# springboot1 **Repository Path**: renchhao/springboot1 ## Basic Information - **Project Name**: springboot1 - **Description**: springboot1 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2016-12-30 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Spring Boot 1-Start ## docs - [spring-boot](https://projects.spring.io/spring-boot/) - [spring-guides](https://spring.io/guides) --- ## intro > Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。通过这种方式,Boot致力于在蓬勃发展的快速应用开发领域(rapid application development)成为领导者。 > 文件略少,特别是一些JavaConfig,超级少,所以很多东西必须的谷歌 --- ## main ### config #### gradle - build.gradle ``` apply plugin: 'spring-boot' apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'io.spring.dependency-management' compileJava.options.encoding = 'UTF-8' buildscript { ext { dependencyManagementPluginVersion = '0.6.0.RELEASE' springBootVersion = '1.4.1.RELEASE' } repositories{ maven { url 'http://repo.spring.io/snapshot' } maven { url 'http://repo.spring.io/milestone' } maven { url 'http://maven.aliyun.com/nexus/content/groups/public'} jcenter() } dependencies { classpath("io.spring.gradle:dependency-management-plugin:${dependencyManagementPluginVersion}") classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") classpath("net.researchgate:gradle-release:2.4.0") } } repositories { maven { url 'http://maven.aliyun.com/nexus/content/groups/public'} jcenter() } dependencyManagement { imports { mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Camden.SR3' mavenBom 'io.spring.platform:platform-bom:Athens-RELEASE' } } idea { module { inheritOutputDirs = false outputDir = file("$buildDir/classes/main/") } } tasks.withType(JavaCompile) { options.encoding = "UTF-8" } dependencies{ testCompile("org.springframework.boot:spring-boot-starter-test") compile("org.springframework.boot:spring-boot-starter") compile("org.springframework.boot:spring-boot-starter-web") compile("mysql:mysql-connector-java:5.1.40") compile("com.h2database:h2") compile("com.alibaba:fastjson:1.2.22") compile("com.google.guava:guava:20.0") } ``` - src/main/resources/application.yml ``` spring: application: name: demo1 server: port: 8001 ``` --- ### code - /springboot1/src/main/java/xin/lowang/springboot/demo1/Demo1Application.java ``` package xin.lowang.springboot.demo1; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; /** * * @author Wang.ch * */ @SpringBootApplication public class Demo1Application { public static void main(String[] args) { new SpringApplicationBuilder(Demo1Application.class).web(true).run(args); } } ``` - /springboot1/src/main/java/xin/lowang/springboot/demo1/web/RestControllerV1.java ``` package xin.lowang.springboot.demo1.web; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * * @author Wang.ch * */ @RestController public class RestControllerV1 { @RequestMapping("/") public String index() { return "hello index"; } @RequestMapping("/say") public String say(String word) { return word; } } ``` --- ### image ![image](http://7fv93h.com1.z0.glb.clouddn.com/89e18b0c3f944942b6c00342955507ae.png) --- ### build ``` gradlew.bat build && java -jar build/libs/springboot1.jar ``` --- ### result - ``` GET http://localhost:8001/ ``` - ``` GET http://localhost:8001/say?word=hello ``` --- ### git ``` https://git.oschina.net/renchhao/springboot1.git ```