zoukankan      html  css  js  c++  java
  • SpringBoot 搭建

    1、使用Eclipse 建立Maven项目(webapp OR quickstart)

    2、配置Maven,如下:

     1  <parent>
     2     <groupId>org.springframework.boot</groupId>
     3     <artifactId>spring-boot-starter-parent</artifactId>
     4     <version>1.2.5.RELEASE</version>
     5     <relativePath/>
     6   </parent>
     7 
     8   <properties>
     9     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    10     <java.version>1.8</java.version>
    11   </properties>
    12 
    13   <dependencies>
    14     <dependency>
    15       <groupId>org.springframework.boot</groupId>
    16       <artifactId>spring-boot-starter-web</artifactId>
    17     </dependency>
    18   </dependencies>
    19 
    20   <build>
    21     <plugins>
    22       <plugin>
    23         <groupId>org.springframework.boot</groupId>
    24         <artifactId>spring-boot-maven-plugin</artifactId>
    25       </plugin>
    26     </plugins>
    27   </build>

    3、建立启动Application

     1 package demo.web.application;
     2 import org.springframework.boot.SpringApplication;  
     3 import org.springframework.boot.autoconfigure.SpringBootApplication;
     4 import org.springframework.context.annotation.ComponentScan;
     5 
     6 @SpringBootApplication 
     7 @ComponentScan(basePackages={"demo.web.*"}) 
     8 public class Application {
     9     public static void main(String[] args) {  
    10         SpringApplication.run(Application.class, args);  
    11     }  
    12 
    13 }

    4、编辑Controller

     1 package demo.web.controller;
     2 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;  
     3 import org.springframework.web.bind.annotation.PathVariable;  
     4 import org.springframework.web.bind.annotation.RequestMapping;  
     5 import org.springframework.web.bind.annotation.RestController;  
     6   
     7 @RestController  
     8 @EnableAutoConfiguration
     9 public class HelloController {
    10     
    11     @RequestMapping("/")  
    12     String home() {  
    13         System.out.println("ee");
    14         return "Hello World!";  
    15     }  
    16       
    17     @RequestMapping("/hello/{myName}")  
    18     String index(@PathVariable String myName) {  
    19         return "Hello "+myName+"!!!";  
    20     }  
    21 
    22 }

    5、通过application.properties对项目进行配置

    server.port=9000  

    项目文件布局如下:

    启动Application程序,即可访问网站。

  • 相关阅读:
    Lua基础之Function
    Lua基础之table详解
    Lua基础之语法
    详解C#中的反射(转载)
    Cocos-x 3.2:从C++过渡到Lua(转载)
    cocos2dx-Lua中出现的问题
    (转载)Cocos2dx-OpenGL ES2.0教程:纹理贴图(6)
    (转载)Cocos2dx-OpenGL ES2.0教程:你的第一个立方体(5)
    hdu 2098 分拆素数和(一个偶数拆分成两个不同素数和 拆法数量)
    51Nod
  • 原文地址:https://www.cnblogs.com/learnMoreEveryday/p/6771354.html
Copyright © 2011-2022 走看看