<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ### 系統要求 ● Java 8 & 兼容java14 . ● Maven 3.3+ ### 修改maven配置 找到maven的配置文件(根據你自己本地下安載的maven路徑) `F:\maven\apache-maven-3.9.2-bin\apache-maven-3.9.2\conf\settings.xml` 這里我們主要修改兩段配置: * mirrors 替換為阿里云鏡像 * profiles 使用jdk1.8進行編譯 ```bash <mirrors> <mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> </mirrors> <profiles> <profile> <id>jdk-1.8</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.8</jdk> </activation> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> </properties> </profile> </profiles> ``` ### HelloWorld 需求:瀏覽發送/hello請求,響應 Hello,Spring Boot ### 確認Idea的Maven配置 ![](https://img.kancloud.cn/bc/0b/bc0b430baa99823ad769a38a1c56295e_1472x518.png =1000x) 這里指定我們自己安裝的maven,和maven配置文件settings.xml ### 創建Maven項目 Idea -- new project -- Maven ![](https://img.kancloud.cn/3e/a9/3ea9037b71a50863b43dc57870b187a3_1164x539.png =1000x) ### pom.xml配置 1.導入springboot父工程: ```bash <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.7.13</version> </parent> ``` 2.添加web依賴 ```bash <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> ``` 添加了web依賴后,可以看到idea左側面板的External Libraries中多了很多jar包,這些都是跟web開發相關的依賴。 ![](https://img.kancloud.cn/9e/50/9e50b08b051029974fed9800e9118940_705x586.png =1000x) 同時,我們也可以通過idea的右側面板的Maven選項卡中查看到下載的依賴列表: ![](https://img.kancloud.cn/4a/86/4a86873ca25ae2ea05295a99f2ff6112_859x395.png =1000x) **完整的pom.xml代碼示例**: ```bash <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.maxiaoke</groupId> <artifactId>boot-01-helloworld</artifactId> <version>1.0-SNAPSHOT</version> <!--導入SpringBoot父工程--> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.7.13</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> </project> ``` ### 編寫SpringBootApplication入口類 package: `com.maxiaoke.boot` class: `MainApplication` ![](https://img.kancloud.cn/86/a2/86a23b94c628bae9d69e0285a0c4c044_521x168.png =1000x) `src/main/java/com/maxiaoke/boot/MainApplication.java` ```bash package com.maxiaoke.boot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * 主程序類 * @SpringBootApplication 這是一個SpringBoot應用 */ @SpringBootApplication public class MainApplication { //主方法 public static void main(String[] args) { SpringApplication.run(MainApplication.class,args); } } ``` ### 創建控制器類 ![](https://img.kancloud.cn/b5/68/b568844835649ed085015c923e9526f2_481x242.png =1000x) `src/main/java/com/maxiaoke/boot/controller/HelloController.java` ```bash package com.maxiaoke.boot.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; //@Controller //@ResponseBody /** * @RestController是@Controller與ResponseBody的合體 * 直接將字符串返回給瀏覽器 */ @RestController public class HelloController { @RequestMapping("/hello") public String handle01() { return "Hello SpringBoot."; } } ``` ### 運行應用 運行入口類的main方法: ![](https://img.kancloud.cn/f7/73/f77319e2b4c7ac3808739a607c967451_894x333.png =1000x) 查看控制臺默認啟動的8080端口: ![](https://img.kancloud.cn/e2/bb/e2bbc4252c11caf1002c36b3b6dca665_1427x366.png =1000x) 通過瀏覽器訪問 localhost:8080 查看 ![](https://img.kancloud.cn/80/fb/80fb97685d7b24fb8501db1139f934c0_536x222.png =1000x)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看