-
Remember about code-style.
-
Don't complicate get by id methods in your DAO, use
session.get()
. -
Remember that we return
Optional
only from dao layer, not from service. Be attentive withsession.get()
, it can return null if data is absent. -
Method names are typically verbs or verb phrases. For example:
get...
,put...
,create...
. Be careful with methods in classWebConfig
. -
Better use
@GetMapping
instead of@RequestMapping(value = "/url", method = RequestMethod.GET)
with methods.@GetMapping
is newer and shorter annotation. -
It is a bad practice to use a URL with a type of operation. You should depend on the HTTP method type when implementing endpoints. Best Practices.
- Wrong:
URL = "/get/{id}"
- Good:
URL = "/{id}"
-
You should return
dto
only in methods on the controller layer (don't return it on service or dao layer). -
Create class
UserResponseDto
in separate packagedto
. -
Remember about
id
. Add this field to the response dto. -
Don't pass
User
object in the constructor ofUserResponseDto
. -
Don't create method
mapFromDtoToEntity(...)
in the mapper class. You should only create method that will map data from entity to dto. -
Use Stream API with
UserController::getAll
, for example, while mapping the users to dto objects to get a list of dtos. -
@GetMapping("/")
is the same that@GetMapping
. -
Use constructor injection instead of:
private AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(AppConfig.class);
private UserService userService = context.getBean(UserService.class);
- Don't push jsp file, jsp dependencies, hello controller and
InternalResourceViewResolver resolver()
bean to PR. - Run checkstyle and fix code style issues.