spring-boot

Should you expose a primary key in REST API URLs?

末鹿安然 提交于 2021-02-11 02:59:22
问题 I'm very new to Spring. I'm trying to create a REST API using Spring Boot and I'm stuck whether to expose my user's primary key or not which also happens to be their email. Something like api/user/example@gmail.com . A big part of me says it's okay since it would sensible to expose it as it is the identifier for that specific record when viewing, deleting, and updating. Is there a security risk for this? What is the best practice for such implementation? Right now I'm combining the

Should you expose a primary key in REST API URLs?

安稳与你 提交于 2021-02-11 02:56:45
问题 I'm very new to Spring. I'm trying to create a REST API using Spring Boot and I'm stuck whether to expose my user's primary key or not which also happens to be their email. Something like api/user/example@gmail.com . A big part of me says it's okay since it would sensible to expose it as it is the identifier for that specific record when viewing, deleting, and updating. Is there a security risk for this? What is the best practice for such implementation? Right now I'm combining the

Spring boot JPA no returning existing result using findById

心不动则不痛 提交于 2021-02-11 02:45:31
问题 I have created a pretty small and simple Spring Boot app using the Oracle database and some JPA queries. This is the code snippet which is not returning data, which is actually exists in database. letterRecipientNonOas = letterRecipientNonOasRepository .findById(Long.valueOf(letterRecipientDTO.getNonOas().getId())) .orElseThrow(() -> new EntityNotFoundException(LetterRecipientNonOas.class, Constant.MESSAGE_ENTITY_NOT_FOUND)); here findById is returning empty result set. this is my repository

cannot resolve configuration property - intellij

非 Y 不嫁゛ 提交于 2021-02-11 01:53:57
问题 I created a bare-minimum springboot project and it keeps complaining about the application.properties entries not being resolved. I have tried lowering the sprintboot version from 2.2.5 to lower ones but still the same issue. My intelliJ version is 2019.3.3 (ultimate version). I do notice that standard spring config properties like below are picked up just fine from application.properties # Cache resources for a day spring.resources.cache.period=86400 Interestingly other projects that worked

How to add Jackson annotations to specific fields on swagger generated model classes for Spring

余生颓废 提交于 2021-02-11 00:04:11
问题 Folks, With swagger 2.0 does anyone know if it's possible to add Jackson annotations to specific fields on swagger generated model classes when using swagger codegen with 'spring' as the 'language' <language>spring</language> ? I want to use Jackson JSON Views & would like to add the view annotations to provide different views of the generated models when I return them from the various REST endpoints. However, I could not find any documentation if any on this on swagger. I see this slightly

How to add Jackson annotations to specific fields on swagger generated model classes for Spring

耗尽温柔 提交于 2021-02-10 23:58:11
问题 Folks, With swagger 2.0 does anyone know if it's possible to add Jackson annotations to specific fields on swagger generated model classes when using swagger codegen with 'spring' as the 'language' <language>spring</language> ? I want to use Jackson JSON Views & would like to add the view annotations to provide different views of the generated models when I return them from the various REST endpoints. However, I could not find any documentation if any on this on swagger. I see this slightly

spring cloud config searchPaths

送分小仙女□ 提交于 2021-02-10 23:39:37
问题 I'm looking at implementing the 12factor approach to externalising config via Spring Cloud Config but am not able to get the wildcards working using searchPaths as I expected. The documentation http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_spring_cloud_config_server mentions that wildcards {application}, {label}, {profile} can be used within the searchPaths variable so that "you can segregate the directories in the path, and choose a strategy that makes sense for you (e

Conditional JsonProperty using Jackson with Spring Boot

混江龙づ霸主 提交于 2021-02-10 23:36:54
问题 A Spring Boot application is tasked with updating a remote integration API every so many minutes. This application can be deployed to a test or prod environment, the application is informed of the end point it should be looking at through an "application.properties" flag. A POJO is being serialized with Jackson and pushed to the endpoint, with the JsonProperty annotations containing the field IDs for the API that it is being pushed to. ie @JsonProperty("field_001) private String name;

Conditional JsonProperty using Jackson with Spring Boot

杀马特。学长 韩版系。学妹 提交于 2021-02-10 23:35:59
问题 A Spring Boot application is tasked with updating a remote integration API every so many minutes. This application can be deployed to a test or prod environment, the application is informed of the end point it should be looking at through an "application.properties" flag. A POJO is being serialized with Jackson and pushed to the endpoint, with the JsonProperty annotations containing the field IDs for the API that it is being pushed to. ie @JsonProperty("field_001) private String name;

Conditional JsonProperty using Jackson with Spring Boot

亡梦爱人 提交于 2021-02-10 23:33:17
问题 A Spring Boot application is tasked with updating a remote integration API every so many minutes. This application can be deployed to a test or prod environment, the application is informed of the end point it should be looking at through an "application.properties" flag. A POJO is being serialized with Jackson and pushed to the endpoint, with the JsonProperty annotations containing the field IDs for the API that it is being pushed to. ie @JsonProperty("field_001) private String name;