src\main\resources\application.properties
?Properties properties = new Properties();
InputStream input = null;
try {
input = <имя вашего класса>.class.getClassLoader()
.getResourceAsStream("application.properties");
properties .load(input);
System.err.println(properties .getProperty("spring.h2.console.enabled"));
@RequestMapping(value = "/some_city/", method = RequestMethod.POST)
public @ResponseBody SomeCity someCity(@RequestParam(value = "somecity", required = true) String somecity) throws Exception {
Gson gson = new Gson();
SomeCity data = gson.fromJson(somecity, SomeCity.class);
return data;
}
@GetMapping("/myGetsomething")
@Transactional
public meDataClass givebyID(@PathVariable("ID") long id) throws NullPointerException {
try {
return postgresService.giveById(id);//возвращает экземпляр класса @Entity
} catch (NullPointerException e) {
throw new DataNotFoundException();
}
}
stat.execute("create table if not exists test(id var(255) primary key, name varchar(255), age int)")
/usr/share/tomcat/bin/catalina.sh stop
pushd /usr/share/tomcat/webapps
cp -R helloworld/ ROOT
/usr/share/tomcat/bin/catalina.sh start
(в helloworld был учебный сервлет типа вашего)curl http://localhost:8080/hello
<h1> Hello world </h1>