我的spring boot项目已连接到mssql服务器,但在postman中点击post响应获取404状态代码时:
Postman :
{
"timestamp": 1625696983693,
"status": 404,
"error": "Not Found",
"path": "/house"
}
mycontroller.java
public class MyController {
@Autowired
private HouseService houseService;
// get the values
@GetMapping("/house")
public List<House> getApiHouseValues(){
return this.houseService.getHouseValues();
}
// add values
@PostMapping("/house")
public GateHouse addApiHouseValues(@RequestBody House house) {
return this.houseService.addHouseValues(house);
}
}
应用程序属性
server.port=9090
spring.datasource.url=jdbc:sqlserver://server-name;databaseName=log
spring.datasource.username=loguser
spring.datasource.password=test
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
# hibernate configuration
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
也签入了sql server,但数据库是空的,不知道哪里出错了。
1条答案
按热度按时间3htmauhk1#
404表示找不到页面,请在控制器级别添加以下内容。