修改build.gradle,右键项目名-gradle-Refresh Gradle Project
gradle开始下载spring的包

build.gradle

/*
 * This build file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java Library project to get you started.
 * For more details take a look at the Java Libraries chapter in the Gradle
 * user guide available at https://docs.gradle.org/4.3/userguide/java_library_plugin.html
 */

// Apply the java-library plugin to add support for Java Library
apply plugin: 'java-library'

// In this section you declare where to find the dependencies of your project
repositories {  
    // Use jcenter for resolving your dependencies.  
    // You can declare any Maven/Ivy/file repository here.  
    maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}  
    jcenter()  
}  

dependencies {
    // This dependency is exported to consumers, that is to say found on their compile classpath.
    api 'org.apache.commons:commons-math3:3.6.1'

    // This dependency is used internally, and not exposed to consumers on their own compile classpath.
    implementation 'com.google.guava:guava:23.0'

    // Use JUnit test framework
    testImplementation 'junit:junit:4.12'
    
    //compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.3.6.RELEASE')  
    
    compile("org.springframework.boot:spring-boot-starter-web:1.3.6.RELEASE")
}

绑定/a/b页面,端口为1234
运行程序,访问localhost:1234/a/b

HelloController.java

package spring_boot;  
  
import org.springframework.boot.SpringApplication;  
import org.springframework.boot.autoconfigure.SpringBootApplication;  
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;  
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;  

import org.springframework.web.bind.annotation.RequestMapping;  
import org.springframework.web.bind.annotation.RequestMethod;  
import org.springframework.web.bind.annotation.RestController;  
  
@RestController  
@RequestMapping("/a")  
@SpringBootApplication  
public class HelloController implements EmbeddedServletContainerCustomizer {  
    public static void main(String[] args) {  
        SpringApplication.run(HelloController.class, args);  
    }   
      
    @RequestMapping(value = "/b", method = RequestMethod.GET)  
    public String home() {  
        return "Hello, world.";  
    }  
  
    @Override  
    public void customize(ConfigurableEmbeddedServletContainer container) {  
        container.setPort(1234);  
    }  
}