spring-boot

Do not include empty object to Jackson

杀马特。学长 韩版系。学妹 提交于 2021-02-17 05:11:33
问题 I am trying to create json with spring boot. class: public class Person { private String name; private PersonDetails details; // getters and setters... } impletentation: Person person = new Person(); person.setName("Apple"); person.setDetails(new PersonDetails()); So there is a instance of Person with empty details and this is exactly what Jackson is returning: "person": { "name": "Apple", "details": {} } I want to have json without empty brackets {} : "person": { "name": "Apple" } This

Datetime behind an hour after insertion. Daylight savings

落爺英雄遲暮 提交于 2021-02-17 03:43:25
问题 I've noticed that my MySql database is subtracting an hour from my DateTime objects when I insert certain dates to my tables. Example: Insert: 2021-03-29 11:44:14.938 Result: 2021-03-29 10:44:14.938 I am inserting Java.Sql.Timestamp object ( timestamp below) using JdbcTemplate.update: jdbcTemplate.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection con) throws SQLException { PreparedStatement stmt = con.prepareStatement( "INSERT INTO

Datetime behind an hour after insertion. Daylight savings

喜夏-厌秋 提交于 2021-02-17 03:40:06
问题 I've noticed that my MySql database is subtracting an hour from my DateTime objects when I insert certain dates to my tables. Example: Insert: 2021-03-29 11:44:14.938 Result: 2021-03-29 10:44:14.938 I am inserting Java.Sql.Timestamp object ( timestamp below) using JdbcTemplate.update: jdbcTemplate.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection con) throws SQLException { PreparedStatement stmt = con.prepareStatement( "INSERT INTO

Spring boot Ambiguous handler

元气小坏坏 提交于 2021-02-17 03:22:30
问题 I use Spring Boot. I created theses two method: @RequestMapping(value = "/user/{userId}", method = RequestMethod.GET) public UserAppDto getNameByUserId(@PathVariable("userId") Long userId) { return userService.getByUserId(userId); } @RequestMapping(value = "/user/{username}", method = RequestMethod.GET) public UserAppDto getNameByUsername(@PathVariable("username") String username) { return userService.getNameByUsername(username); } When i try to log in the web application, i get: java.lang

Spring security session timeout for spring reactive

泪湿孤枕 提交于 2021-02-16 22:59:37
问题 I have a Reactive Application with Spring Security integrated, it was created by spring initilizer with mainly thre3 packages(spring boot, spring security and webflux). I was trying to configure the session timeout by following configuration in application.properties : spring.session.timeout=1m after starting the application with mvn spring-boot:run , It can be accessed by http://localhost:8080 and it asked me to login(by default security setting). I can use the username user and the password

How to modify or custom sessionId in spring session project?

a 夏天 提交于 2021-02-16 20:57:44
问题 My project use Spring Boot and Spring Session,now i want to modify or custom sessionId before session data persistence in redis,How should I do? thanks! 回答1: Maybe you need to go through the docs Spring Session works well with spring boot Docs :http://docs.spring.io/spring-session/docs/current/reference/html5/ It will tell you that coupling the custom implementation with @EnableSpringHttpSession support allow to easily reuse existing Spring Session configuration facilities and infrastructure.

How to modify or custom sessionId in spring session project?

筅森魡賤 提交于 2021-02-16 20:53:09
问题 My project use Spring Boot and Spring Session,now i want to modify or custom sessionId before session data persistence in redis,How should I do? thanks! 回答1: Maybe you need to go through the docs Spring Session works well with spring boot Docs :http://docs.spring.io/spring-session/docs/current/reference/html5/ It will tell you that coupling the custom implementation with @EnableSpringHttpSession support allow to easily reuse existing Spring Session configuration facilities and infrastructure.

Stackoverflow error when saving an Object's toString value - Java/Hibernate/Spring

ぐ巨炮叔叔 提交于 2021-02-16 20:07:37
问题 I have the following sample entities: Institution @Data @Entity @NoArgsConstructor @EntityListeners(InstitutionAuditListener.class) public class Institution extends Auditable<String> { @OneToMany(mappedBy = "institution", cascade = CascadeType.ALL) @JsonManagedReference private List<RegisteredProgram> registeredPrograms; private String name; } RegisteredProgram @Data @NoArgsConstructor @Entity @EntityListeners(RegisteredProgramAuditListener.class) public class RegisteredProgram extends

Stackoverflow error when saving an Object's toString value - Java/Hibernate/Spring

谁说胖子不能爱 提交于 2021-02-16 20:07:17
问题 I have the following sample entities: Institution @Data @Entity @NoArgsConstructor @EntityListeners(InstitutionAuditListener.class) public class Institution extends Auditable<String> { @OneToMany(mappedBy = "institution", cascade = CascadeType.ALL) @JsonManagedReference private List<RegisteredProgram> registeredPrograms; private String name; } RegisteredProgram @Data @NoArgsConstructor @Entity @EntityListeners(RegisteredProgramAuditListener.class) public class RegisteredProgram extends

Setting jsessonid cookie to SameSite=Strict attribute in spring boot?

你说的曾经没有我的故事 提交于 2021-02-16 19:45:16
问题 What is the spring-boot configuration to set jsessionId cookie as SameSite=Strict. JsessionId need to add SameSite=Strict or existing cookie not new cookie generation.Is it support? 回答1: I used Rfc6265CookieProcessor to configure SameSite flag in the spring boot application as a workaround. build.gradle : dependencies { implementation 'org.springframework.boot:spring-boot-starter-tomcat' ... } Config in the main class: @Bean public ServletWebServerFactory servletContainer() { return new