SpringBoot-05:SpringBoot初运行以及tomcat端口号的修改

------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥-------------

上篇博客讲了,如何创建SpringBoot工程,所以,我本篇博客讲述,如何跑起来自己的第一个案例

1.准备一个类,让他成为控制器,Controller,springboot的web项目默认就有与springmvc集成,所以,往下看

package cn.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Dawn on 2018/6/24.
 */
@RestController
/*@RestController有点像@[email protected],他这个控制器下的所有,都是返回json串*/
public class FirstController
{
    @RequestMapping("/sayHello")
    public String sayHello(){
        return "sayHi";
    }
}

2.运行项目创建就有的那个类的main方法,他就可以启动springboot自己默认集成的tomcat服务器

3.如果成功之后,就可以正常访问,通过类似http://localhost:8080/你刚才的requestmappring的路径

8080是tomcat默认端口号,如果要改的话,只需要在application.properties中加一行即可

#tomcat
server.port=19090

原文地址:https://www.cnblogs.com/DawnCHENXI/p/9220953.html

时间: 2024-10-14 20:58:46

SpringBoot-05:SpringBoot初运行以及tomcat端口号的修改的相关文章

错误记录--更改tomcat端口号方法,Several ports (8005, 8080, 8009)

启动Tomcat服务器报错: Several ports (8005, 8080, 8009) required by Tomcat v5.5 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to sto

Linux下Tomcat端口号以及进程

 Linux下Tomcat端口号以及进程 1,查看tomcat进程: ps -aux | grep tomcat(或者ps -ef | grep tomcat都行) 可以看到现在运行着两个tomcat进程,一个进程的pid为9974,另一个pid为23422.  2,根据进程查看端口号: sudo netstat -naop | grep 23422 这是查看pid为23422的进程占用的端口号: 可以看到9300和9399端口号被占用,其中9399是tomact Server的SHUTDOWN

tomcat端口号被占用或者修改端口号的解决方法

一)修改端口号: 在tomcat文件中找到conf里面的server.xml 在tomcat解压后的文件中按照下图操作  打开该文件 文件打开后(如下图)Tomcat默认的8080 端口,系统默认的配置 将Tomcat服务器启动的端口修改为8081端口 这样就把原来的端口修改为8081端口,不过在修改配置文件(*.xml)后,Tomcat服务器要重新启动 修改之前的端口号: 修改之后的端口号: 重启后:访问Tomcat服务器也必须以新的访问端口去访问:http://localhost:8081/

Tomcat 服务器的端口号的修改

在系统中找到Tomcat安装目录下的conf文件夹下的servlet.xml文件. (1)在servlet.xml文件中找到以下代码: <connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> (2)将上面代码中的port="8080"修改为port="8081

错误记录--更改tomcat端口号方法,Several ports (8005, 8080, 8009)(转)

启动Tomcat服务器报错: Several ports (8005, 8080, 8009) required by Tomcat v5.5 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to sto

错误记录--更改tomcat端口号方法,Several ports (8005, 8080, 8009)【转】

启动Tomcat服务器报错: Several ports (8005, 8080, 8009) required by Tomcat v5.5 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to sto

tomcat端口号被占用

Eclipse启动TomCat报错:Several ports (8080, 8009) required by Tomcat v8.0 are already in use. Eclipse启动Tomcat错误: Several ports (8080, 8009) required by Tomcat v8.0 Server at localhost are already in use. The server may already be running in another proces

Spring Boot 源码之 内嵌Tomcat端口号赋值逻辑

一.Cumtomizer的Bean的定义 EmbeddedServletContainerAutoConfiguration.java 在处理自动配置的时候,扫描到这个Bean,注册到了BeanFactory里面 @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @Configuration @ConditionalOnWebApplication(type = Type.SERVLET) @EnableConfigurationProperties

tomcat端口号被占用问题

1  netstat -ano| findstr 8761 2 taskkill /f/t/im 5156 原文地址:https://www.cnblogs.com/yachao1120/p/11693205.html