springboot怎么返回404_Spring Boot:Rest URL返回404

我正在开发一个简单的Spring Boot基础休息应用程序,它已部署到带有jndi数据源的外部tomcat服务器中 . 当我运行应用程序时,数据库被创建,这意味着应用程序能够读取实体类并创建hibernate ddl . 但是,当我尝试从邮递员点击其余URL时,会返回404错误消息 . 这是在我将应用程序移动到外部服务器之后发生的,当我使用嵌入式服务器时我能够访问网址 . 有人能帮我弄清楚我做错了什么吗?

Main method:

package com.nb;

@SpringBootApplication

public class SpringBootWithSpringDataJpaApplication extends SpringBootServletInitializer{

public static void main(String[] args) {

SpringApplication.run(SpringBootWithSpringDataJpaApplication.class, args);

}

@Override

protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

return application.sources(SpringBootWithSpringDataJpaApplication.class);

}

Controller:

package com.nb.springboot.topic;

@RestController

public class TopicController {

@Autowired

private TopicService topicService;

@RequestMapping("/topics")

public List getAllTopics(){

return topicService.getAllTopics();

}

@RequestMapping("/topics/{id}")

public Topic getTopic(@PathVariable("id") String id){

return topicService.getTopic(id);

}

@RequestMapping(method=RequestMethod.POST, value="/topics")

public void addTopic(@RequestBody Topic topic){

topicService.addTopic(topic);

}

@RequestMapping(method=RequestMethod.PUT, value="/topics/{id}")

public void updateTopic(@RequestBody Topic topic, @PathVariable String id){

topicService.updateTopic(topic, id);

}

@RequestMapping(method=RequestMethod.DELETE, value="/topics/{id}")

public void deleteTopic(@PathVariable String id){

topicService.deleteTopic(id);

}

}

http://localhost8080/SpringBootWithSpringDataJPA/topics/java ------在tomcat 8(外部)中不起作用,其中SpringBootWithSpringDataJPA是我的项目名称 .

application.properties文件是:

spring.datasource.jndi名=的java:/ comp / env的/ JDBC / postgres的/ springbootDS

spring.jpa.hibernate.ddl-AUTO =创建

spring.jpa.show-SQL =真

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值