入门:编写java类+启动类——笔记3

1.创建java类

2.编写

package com.itheima.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class hellp {
    @RequestMapping("/hello")
    public String hello(){
        return "hello world";
    }
}

3.运行

package要对应,如果要新建package,记得检查。

4.结果

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.3.4)

2024-10-07T13:01:56.867+08:00  INFO 15612 --- [demo] [           main] com.itheima.demo.DemoApplication         : Starting DemoApplication using Java 17.0.12 with PID 15612 (C:\springprogram\p2\demo\target\classes started by 25511 in C:\springprogram\p2)
2024-10-07T13:01:56.873+08:00  INFO 15612 --- [demo] [           main] com.itheima.demo.DemoApplication         : No active profile set, falling back to 1 default profile: "default"
2024-10-07T13:01:58.374+08:00  INFO 15612 --- [demo] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2024-10-07T13:01:58.396+08:00  INFO 15612 --- [demo] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-10-07T13:01:58.396+08:00  INFO 15612 --- [demo] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.30]
2024-10-07T13:01:58.495+08:00  INFO 15612 --- [demo] [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-10-07T13:01:58.496+08:00  INFO 15612 --- [demo] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1511 ms
2024-10-07T13:01:58.972+08:00  INFO 15612 --- [demo] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path '/'
2024-10-07T13:01:58.981+08:00  INFO 15612 --- [demo] [           main] com.itheima.demo.DemoApplication         : Started DemoApplication in 2.915 seconds (process running for 4.589)
2024-10-07T13:07:20.313+08:00  INFO 15612 --- [demo] [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2024-10-07T13:07:20.329+08:00  INFO 15612 --- [demo] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2024-10-07T13:07:20.391+08:00  INFO 15612 --- [demo] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 62 ms

Spring Boot:显示是Spring工程,版本号3.3.4

Tomcat initialized with port 8080 (http):tomcat自动启动,绑定的端口号是8080.

测试:网页输入http://localhost:8080/hello

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值