Posts

Showing posts from May, 2015

Spring Boot Internationalization with Default Locale for Message Strings

Image
How to add Spring Boot Internationalization with Default Locale for Storing Message Strings such as Validation Messages in a message.properties file 
 This article will show you how to use a properties file to define static text in your application such as for validation message.

All the code is appended at the bottom of the article. 

Add Default locale and Message Source beans to your Application class 

 Add these classes to set your default locale and configure the location of your message properties file



Add a Service and Interface to retrieve message text 
 This service will pull the default locale from the session and then get the message text from your properties file using the messageSource.


In your controller, use the Message service to get the message text 
 You will inject the message service in the controller and then pass in the id to get the value from the props file




Create the message.properties file in the locale folder 
 In resources, create the locale folder and t…

Change Port on a Spring Boot Application when using intelliJ

Image
Change Port on a Spring Boot Application when using intelliJ 

Two ways to change the port that the embedded Tomcat is using in a Spring Boot Application.
The first way is to modify the application properties in the resources folder:



There are a couple issues with this approach.  You might only want this port change in your local environment and if you check it in by accident you might break things.

Alternatively, you can use a command line parameter.
Go to Run -> Edit Configurations -> VM options
Then enter in the following argument:
-Dserver.port=8090

Then click apply and OK and attempt to run the application again.