我正在构建一个REST API来访问数据库,并且遇到麻烦/持续出现白页错误。在圆圈中运行,试图在程序的流程或逻辑中找到我的错误和/或我的错误。
这是我的应用程序:
package com.skilldistillery.myRest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@SpringBootApplication
@ComponentScan(basePackages= {"com.skilldistillery.edgemarketing"})
@EntityScan("com.skilldistillery.edgemarketing")
@EnableJpaRepositories("com.skilldistillery.myRest.repositories")
public class MyRestApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(MyRestApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(MyRestApplication.class, args);
}
}
我的控制器:
package com.skilldistillery.myRest.controllers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.skilldistillery.edgemarketing.entities.House;
import com.skilldistillery.myRest.services.HouseService;
@RestController
@RequestMapping("api")
@CrossOrigin({ "*", "http://localhost:4200" })
public class HouseController {
@Autowired
HouseService houseServ;
@GetMapping("index/{id}")
public House show(@PathVariable("id") Integer id) {
return houseServ.show(id);
}
}
它编译并启动,但通过邮递员和浏览器,我得到白页错误。我在互联网上搜索过,试图了解我哪里出了问题,但没有找到它。请指教。
天涯尽头无女友
相关分类