使用IDEA创建SpringBoot项目 - Go语言中文社区

使用IDEA创建SpringBoot项目


使用IDEA创建SpringBoot项目

项目环境

  • IDEA 2019.1
  • SpringBoot 2.1.5
  • Gradle 4.10
  • JDK 1.8

操作步骤

server:
  #指定端口 
  port: 8880
  • 下面时项目的结构:
    在这里插入图片描述
  • 在org.virtue包下创建controller包,并在该包中创建HelloController.java文件作为测试,代码如下:

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloController {
    @ResponseBody
    @RequestMapping(value = "/hello", method = {RequestMethod.GET})
    public String hello(){
        return "hello";
    }
}
  • 启动FastSpringbootApplication,启动过程中日志如下:
  .   ____          _            __ _ _
 /\ / ___'_ __ _ _(_)_ __  __ _    
( ( )___ | '_ | '_| | '_ / _` |    
 \/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |___, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.5.RELEASE)

2019-05-18 22:30:20.205  INFO 33556 --- [           main] org.virtue.FastSpringbootApplication     : Starting FastSpringbootApplication on 13XK9CRTRMLYN7L with PID 33556 (F:projectfast_springbootbuildclassesjavamain started by Administrator in F:projectfast_springboot)
2019-05-18 22:30:20.207  INFO 33556 --- [           main] org.virtue.FastSpringbootApplication     : No active profile set, falling back to default profiles: default
2019-05-18 22:30:20.740  INFO 33556 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8880 (http)
2019-05-18 22:30:20.754  INFO 33556 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-05-18 22:30:20.755  INFO 33556 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.19]
2019-05-18 22:30:20.811  INFO 33556 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-05-18 22:30:20.812  INFO 33556 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 583 ms
2019-05-18 22:30:20.924  INFO 33556 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-05-18 22:30:21.030  INFO 33556 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8880 (http) with context path ''
2019-05-18 22:30:21.032  INFO 33556 --- [           main] org.virtue.FastSpringbootApplication     : Started FastSpringbootApplication in 1.061 seconds (JVM running for 1.81)
2019-05-18 22:31:09.879  INFO 33556 --- [nio-8880-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-05-18 22:31:09.880  INFO 33556 --- [nio-8880-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2019-05-18 22:31:09.884  INFO 33556 --- [nio-8880-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 4 ms

项目代码

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq_27520051/article/details/90321657
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2021-05-14 00:35:54
  • 阅读 ( 1076 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢