spring boot 返回php,spring boot启动后结束

由于新的项目需要,新项目不再使用php开发,采用java语言开发。今天重新搭建尝试搭建spring boot项目,使用的开发工具是IntelliJ IDEA,用maven管理包,mybatis做持久层,综合起来大体的架构和技术选型是spring boot+mybatis+maven+mysql

创建完成项目后,主要的几个文件和类如下:

项目入口的类CaseManageApplication.class

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication

public class CaseManageApplication {

public static void main(String[] args) {

SpringApplication.run(CaseManageApplication.class, args);

}

}

maven的pom.xml

1.8

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-tomcat

provided

org.springframework.boot

spring-boot-starter-test

test

org.springframework.boot

spring-boot-maven-plugin

测试controller类:

/**

* @Author: kewin.cheng

* @Date: 10/12/19 9:59 AM

*/

@RestController

@RequestMapping("test/")

public class TestController {

@RequestMapping("index")

public String index() {

return "hello world!";

}

}

配置application.properties文件,配置下端口

server.port=8080

执行main主类,响应日志显示直接退出如下:

Process finished with exit code 0

预期效果是项目执行成功,可以通过http://127.0.0.1:8080/test/index访问项目返回hello world,但是系统直接退出

为什么创建spring boot的demo项目执行不成功,问题出现在这个配置上

org.springframework.boot

spring-boot-starter-tomcat

provided

解决方案:spring boot自带了tomcat,但是要去掉provided这一行系统才会正常运行,去掉后系统成功运行再次访问http://127.0.0.1:8080/test/index返回成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值