zoukankan      html  css  js  c++  java
  • SpringBoot(一)最佳实例

     1 package com.wykd.wboot.base;
     2 
     3 import org.springframework.boot.SpringApplication;
     4 import org.springframework.boot.autoconfigure.SpringBootApplication;
     5 import org.springframework.web.bind.annotation.RequestMapping;
     6 import org.springframework.web.bind.annotation.RestController;
     7 
     8 @RestController
     9 @SpringBootApplication
    10 public class WbootApplication {
    11 
    12     @RequestMapping("/index")
    13     public String index(){
    14         return "Hello Spring Boot";
    15     }
    16     public static void main
    17             (String[] args) {
    18         SpringApplication.run(WbootApplication.class, args);
    19     }
    20     
    21 //    /**
    22 //     * 使用fastjson解析框架
    23 //     * @return
    24 //     */
    25 //    @Bean
    26 //    public HttpMessageConverters fastJsonHttpMessageConverters() {
    27 //        FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
    28 //        FastJsonConfig fastJsonConfig = new FastJsonConfig();
    29 //        fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
    30 //        fastConverter.setFastJsonConfig(fastJsonConfig);
    31 //        HttpMessageConverter<?> converter = fastConverter;
    32 //        return new HttpMessageConverters(converter);
    33 //    }
    34 //import com.alibaba.fastjson.serializer.SerializerFeature;
    35 //import com.alibaba.fastjson.support.config.FastJsonConfig;
    36 //import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
    37 //import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
    38 //import org.springframework.context.annotation.Bean;
    39 //import org.springframework.http.converter.HttpMessageConverter;
    40 
    41 
    42 
    43 
    44 }
    WbootApplication启动类

    pom.xml文件内容如下:

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     4     <modelVersion>4.0.0</modelVersion>
     5 
     6     <groupId>com.wykd</groupId>
     7     <artifactId>wboot</artifactId>
     8     <version>0.0.1-SNAPSHOT</version>
     9     <packaging>jar</packaging>
    10 
    11     <name>wboot</name>
    12     <description>Demo project for Spring Boot</description>
    13 
    14     <parent>
    15         <groupId>org.springframework.boot</groupId>
    16         <artifactId>spring-boot-starter-parent</artifactId>
    17         <version>2.0.1.RELEASE</version>
    18         <relativePath/> <!-- lookup parent from repository -->
    19     </parent>
    20 
    21     <properties>
    22         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    23         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    24         <java.version>1.8</java.version>
    25     </properties>
    26 
    27     <dependencies>
    28         <dependency>
    29             <groupId>org.springframework.boot</groupId>
    30             <artifactId>spring-boot-starter-web</artifactId>
    31         </dependency>
    32 
    33         <dependency>
    34             <groupId>org.springframework.boot</groupId>
    35             <artifactId>spring-boot-starter-test</artifactId>
    36             <scope>test</scope>
    37         </dependency>
    38 
    39         <!-- 添加fastjson 依赖包. -->
    40         <dependency>
    41             <groupId>com.alibaba</groupId>
    42             <artifactId>fastjson</artifactId>
    43             <version>1.2.28</version>
    44         </dependency>
    45 
    46         <!--添加依赖-->
    47         <dependency>
    48             <groupId>org.springframework.boot</groupId>
    49             <artifactId>spring-boot-devtools</artifactId>
    50             <!-- optional=true,依赖不会传递,该项目依赖devtools;之后依赖myboot项目的项目如果想要使用devtools,需要重新引入 -->
    51             <optional>true</optional>
    52         </dependency>
    53 
    54     </dependencies>
    55 
    56 
    57 
    58 
    59 </project>
  • 相关阅读:
    BZOJ1406: [AHOI2007]密码箱 数论
    BZOJ5188: [Usaco2018 Jan]MooTube 并查集+离线处理
    BZOJ2662: [BeiJing wc2012]冻结 spfa+分层图
    BZOJ1297: [SCOI2009]迷路 矩阵快速幂
    BZOJ4887: [Tjoi2017]可乐 矩阵快速幂
    BZOJ5168: [HAOI2014]贴海报 线段树
    开发富文本编辑器的一些经验教训
    数据可视化的发展前景、商业/职业前景?
    市场调研中如何做数据分析?
    当前火热的短视频,背后有着哪些黑科技技术?
  • 原文地址:https://www.cnblogs.com/csuwangwei/p/9157747.html
Copyright © 2011-2022 走看看