zoukankan      html  css  js  c++  java
  • spring boot web服务

    [root@d java]# tree -I target

    .
    ├── pom.xml
    └── src
    ├── main
    │   ├── java
    │   │   └── com
    │   │   └── neo
    │   │   ├── controller
    │   │   │   └── HelloController.java
    │   │   └── HelloApplication.java
    │   └── resources
    └── test
    └── java

    9 directories, 3 files
    [root@d java]#

    pom.xml

    <?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.neo</groupId>
    <artifactId>spring-boot-hello</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <name>spring-boot-hello</name>
    <description>Demo project for Spring Boot</description>

    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.RELEASE</version>
    </parent>

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    </properties>

    <dependencies>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    </dependency>
    </dependencies>
    <build>
    <plugins>
    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    </build>
    </project>


    com.neo.HelloApplication

    package com.neo;

    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.SpringApplication;

    @SpringBootApplication
    public class HelloApplication {
    public static void main(String[] args) {
    SpringApplication.run(HelloApplication.class, args);
    }
    }

    com.neo.controller.HelloController
    package com.neo.controller;
    import org.springframework.web.bind.annotation.RestController;
    import org.springframework.web.bind.annotation.RequestMapping;
    @RestController
    public class HelloController {
    @RequestMapping("/")
    public String index(){
    return "Hello Spring Boot 2.0!";
    }
    @RequestMapping("/t123")
    public String t123(){
    return "this.t123()"+this.getClass().getName()+Thread.currentThread().getStackTrace()[1].getMethodName();
    }
    }


    [root@d java]# mvn clean; mvn compile;mvn package;
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building spring-boot-hello 1.0
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ spring-boot-hello ---
    [INFO] Deleting /data/gateway/java/target
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 0.493s
    [INFO] Finished at: Tue Dec 04 10:45:22 CST 2018
    [INFO] Final Memory: 14M/481M
    [INFO] ------------------------------------------------------------------------
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building spring-boot-hello 1.0
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ spring-boot-hello ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 0 resource
    [INFO] Copying 0 resource
    [INFO]
    [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ spring-boot-hello ---
    [INFO] Changes detected - recompiling the module!
    [INFO] Compiling 2 source files to /data/gateway/java/target/classes
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1.593s
    [INFO] Finished at: Tue Dec 04 10:45:25 CST 2018
    [INFO] Final Memory: 23M/607M
    [INFO] ------------------------------------------------------------------------
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building spring-boot-hello 1.0
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ spring-boot-hello ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 0 resource
    [INFO] Copying 0 resource
    [INFO]
    [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ spring-boot-hello ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO]
    [INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ spring-boot-hello ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory /data/gateway/java/src/test/resources
    [INFO]
    [INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ spring-boot-hello ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO]
    [INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ spring-boot-hello ---
    [INFO] No tests to run.
    [INFO]
    [INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ spring-boot-hello ---
    [INFO] Building jar: /data/gateway/java/target/spring-boot-hello-1.0.jar
    [INFO]
    [INFO] --- spring-boot-maven-plugin:2.0.0.RELEASE:repackage (default) @ spring-boot-hello ---
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1.883s
    [INFO] Finished at: Tue Dec 04 10:45:28 CST 2018
    [INFO] Final Memory: 19M/481M
    [INFO] ------------------------------------------------------------------------
    [root@d java]# java -jar target/spring-boot-hello-1.0.jar com.neo.HelloApplication

    http://11.21.1.2:8080/t123

    this.t123()com.neo.controller.HelloControllert123

  • 相关阅读:
    python 绘制所有线条、散点等 可用的标记符号(marker)
    Maximal InformMaximal Information Coefficient (MIC)最大互信息系数详解与实现 https://blog.csdn.net/FontThrone/article/details/85227239
    python画图,等间距坐标距离表示不等间距数据值
    机器学习数据库 http://archive.ics.uci.edu/ml/datasets.php https://www.openml.org/d/179
    Matplotlib.pyplot.plot图形符号、风格及颜色简写形式速查表https://blog.csdn.net/Treasure99/article/details/106044114/
    Pycharm 2017.3 永久激活教程https://www.bilibili.com/read/cv11643882/
    学习资源http://imada.huel.edu.cn/resource.html# 数据库/机器学习/安全领域顶会论文
    Python的知识点 plt.plot()函数细节
    原因是标题默认输出英文,如果输出中文,要对字体进行调整。需要在程序定义前输入:
    会讲故事助你成功
  • 原文地址:https://www.cnblogs.com/rsapaper/p/10062711.html
Copyright © 2011-2022 走看看