diff --git a/II. Getting started/11.3. Writing the code.md b/II. Getting started/11.3. Writing the code.md index e69de29..ccb5a66 100644 --- a/II. Getting started/11.3. Writing the code.md +++ b/II. Getting started/11.3. Writing the code.md @@ -0,0 +1,25 @@ +### 11.3. 编写代码 + +为了完成应用程序,我们需要创建一个单独的Java文件。Maven默认会编译`src/main/java`下的源码,所以你需要创建那样的文件结构,然后添加一个名为`src/main/java/Example.java`的文件: +```java +import org.springframework.boot.*; +import org.springframework.boot.autoconfigure.*; +import org.springframework.stereotype.*; +import org.springframework.web.bind.annotation.*; + +@RestController +@EnableAutoConfiguration +public class Example { + + @RequestMapping("/") + String home() { + return "Hello World!"; + } + + public static void main(String[] args) throws Exception { + SpringApplication.run(Example.class, args); + } + +} +``` +尽管这里没有太多代码,但很多事情正在发生。让我们分步探讨重要的部分。