<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          SpringBoot 學(xué)習(xí)——SpringBoot 入門 HelloWorld

          共 2033字,需瀏覽 5分鐘

           ·

          2017-04-11 17:12

          SpringBoot學(xué)習(xí)——SpringBoot入門HelloWorld

          相關(guān)資源

          官網(wǎng)地址:http://projects.spring.io/spring-boot/

          創(chuàng)建maven項(xiàng)目

          勾選箭頭處,創(chuàng)建一個(gè)簡(jiǎn)單的項(xiàng)目

          填寫groupId和artifactId,點(diǎn)擊確定

          配置pom.xml

          官方網(wǎng)址有相關(guān)配置,本文采用1.5.1版本的,完整pom
          注意,如果要打成可執(zhí)行jar包,要指定jar包的主函數(shù)

          
              4.0.0
              HelloConsumer
              HelloConsumer
              0.0.1-SNAPSHOT
          
              
              
                  org.springframework.boot
                  spring-boot-starter-parent
                  1.5.1.RELEASE
              
          
              
              
                  
                      
                          org.springframework.boot
                          spring-boot-maven-plugin
                      
                      
                      
                          org.apache.maven.plugins
                          maven-jar-plugin
                          
                              
                                  
                                      true
                                      com.pzr.consumer.test.OfficialDemo
                                  
                              
                          
                      
                  
              
          
              
              
                  
                  
                      org.springframework.boot
                      spring-boot-starter-web
                  
              
          
          

          編寫測(cè)試java類

          package com.pzr.consumer.test;
          
          import org.springframework.boot.SpringApplication;
          import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
          import org.springframework.stereotype.Controller;
          import org.springframework.web.bind.annotation.RequestMapping;
          import org.springframework.web.bind.annotation.ResponseBody;
          
          /**
           * 官方例子
           * @author pzr
           *
           */
          @Controller
          @EnableAutoConfiguration
          public class OfficialDemo {
              @RequestMapping("/test")
              @ResponseBody
              String home() {
                  return "Hello World!";
              }
          
              public static void main(String[] args) throws Exception {
                  SpringApplication.run(OfficialDemo.class, args);
              }
          }

          更新maven項(xiàng)目

          pom.xml修改完成后,需要更新項(xiàng)目
          項(xiàng)目右鍵-Maven4MyEclipse-Update project或者快捷鍵alt+F5

          完整的項(xiàng)目結(jié)構(gòu)

          運(yùn)行java

          運(yùn)行OfficialDemo

          在瀏覽器地址欄輸入:http://localhost:8080/test

          運(yùn)行jar

          清理-編譯-打包

          右鍵項(xiàng)目-Run As-Maven build

          在Goals寫入clean再點(diǎn)擊Run
          清理成功后,執(zhí)行上個(gè)步驟,寫入compile,點(diǎn)擊Run
          編譯成功后,執(zhí)行上個(gè)步驟,寫入package,點(diǎn)擊Run

          打包成功后,會(huì)在項(xiàng)目的target目錄下生成對(duì)應(yīng)的jar包

          運(yùn)行

          將jar包拷貝到c盤下,打開命令控制臺(tái)alt+R,輸入cmd回車
          到c盤目錄下運(yùn)行命令

          在瀏覽器地址欄輸入:http://localhost:8080/test

          出現(xiàn)問題

          打包時(shí)一定要在pom中指定運(yùn)行主函數(shù)

          瀏覽 105
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  天干夜天干天天天爽视频 | 13一16女处被毛片视频 | 欧美极品在线 | 北条麻妃无码观看 | 狼人亚洲|