[JAVA] Spring-security error message cannot be changed

keyword

No change from "Bad Credential" ...

problem

Introducing spring-security in Spring (not Spring-Boot) When I implemented login authentication, I was worried that when I output the error wording when I entered the wrong ID or path, only the characters set by default are displayed.

Cause

Bean definition of MessageResource Isn't it done on the DispatcherServlet side (servlet-context.xml)?

Solution

It worked when I did it on the ContextLoaderListner side (applicatinoContext.xml).

Cause details

When running as a web application in Spring It is necessary to set the following two application contexts.

The two have a parent-child relationship, and the parent can refer to the child's bean, but not the other way around. So, if you DI the messageResource as a parent It occurs because it cannot be referenced by the child who is DI for spring-security.

IMG_4263.JPG

reference

When developing with Spring, it is difficult to solve without knowledge of the following major premises, so it is good to keep it down

Recommended Posts

Spring-security error message cannot be changed
Android Studio JRE cannot be changed
RubyOnRails, Authentication plugin'caching_sha2_password' cannot be loaded error solution
Rails error messages cannot be translated into Japanese
Because getSupportLoaderManager cannot be used
Java Stream cannot be reused.
Javadoc generation error: This character cannot be mapped to encoding MS932
Minecraft Forge error: This character cannot be mapped to encoding MS932