zoukankan      html  css  js  c++  java
  • Spring Boot Web Executable Demo

    Spring Boot Web Executable Demo

    Spring Boot Web Executable Demo

    Table of Contents

    1 Step by Step

    • 新建intellij project maven 项目
    • 加入pom依赖
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.5.RELEASE</version>
    </parent>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
    
    • 新建入口类
    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;
    
    /**
     * Created by csophys on 16/8/31.
     */
    @Controller
    @EnableAutoConfiguration
    public class ExecutorController {
    
        @RequestMapping("/")
        @ResponseBody
        public String hello(){
            return "hello world";
        }
    
        public static void main(String[] args) {
            SpringApplication.run(ExecutorController.class,args);
        }
    }
    
    • 静态资源处理
    resources下新建static 目录,static目录下新建index.html 文件可以默认访问到
    
    • 启动入口类,浏览器访问成功
    • 生成可执行的jar
    1. 修改xml
    加入
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    2. 执行jar
    java -jar /Users/csophys/code/downloadVoiceFileWithConnid/target/csophys-1.0-SNAPSHOT.jar
    

    Author: 陈胜 csophys

    Created: 2017-01-15 Sun 21:53

    Validate

  • 相关阅读:
    C# decimal保留指定的小数位数,不四舍五入
    C# :实现水印与图片合成,并利用Graphics 压缩图像质量 , (委托实现listBox的动态添加提示)
    手机游戏模拟器汇总 用于开发
    WinAPI 操作串口
    C#图片压缩算法
    SQL SERVER 2008 无法启动TSQL调试的解决方法
    C#放缩、截取、合并图片并生成高质量新图的类
    C#图片处理之: 另存为压缩质量可自己控制的JPEG
    URL及short URL短网址
    1的补码及2的补码
  • 原文地址:https://www.cnblogs.com/csophys/p/6287992.html
Copyright © 2011-2022 走看看