Spring Profiles

Spring Profiles allow users to use various configurations, register different beans etc. Working on different environments may cause some problems or we need to run with quick setup on our development environment. To make it more clear, we can mention to database issues.

One of my colleague may change hibernate mappings. To get rid of schema compatibility problems, I want to create database schemas on every run at my development environment. When it comes to deployment releases, migration scripts will create database and schemas so I won’t need to create it programmatically.

For the sample case mentioned above, I create 2 different spring profile as following:

 

If -Dspring.profiles.active=dev is given as JVM options, dev profile is loaded. In case of not specifiying active profile explicitly, default profile is loaded as default.

For further reading, please look at following links:

 

Run bat files as Windows Service with NSSM

I found NSSM on this StackOverflow link when I was searching for a tool to run bat files as windows service. It is really easy to use. I show you a simple usage, just follow the steps below.

Steps
  1. Download and extract it
  2. Open command window in the directory of nssm.exe
  3. Type nssm install SimpleService
  4. Set application path and display name for your batch file
  5. Click Install Service

 

nssm

Here is my simple batch script