Articles of November 2013

Using Embedded Jetty With Spring MVC

  • access_time 5 years ago
  • date_range 27/11/2013
  • comment 4
  • share 11
  • label_outlineSpring, Spring MVC

Update 12/2017: Just use spring-boot-starter-jetty. For more info refer to the docs.

There could be some advantages in creating standalone web application versus packaging it as WAR and deploying it to container. Avoiding delving into debate, what I can think of is that such application could be easier to deploy/upgrade/restart, especially in situation when there are more web applications living in the container. For example, in case of Jetty, hot-deployment does not always work as expected, causing the need to restart whole thing, which in turn takes time during which applications are offline. Such app is also less prone to possible problems associated with setting up and later upgrading of the container as they come "bundled" with exact flavour they were probably integration-tested with.

Spring MVC without web.xml using WebApplicationInitializer

  • access_time 5 years ago
  • date_range 05/11/2013
  • comment 12
  • share 34
  • label_outlineSpring, Spring MVC

Update 12/2017: Thankfully this is no longer needed, really. Keeping for posterity.

Few months ago I started playing with Spring Framework, which I really enjoy. Looking for the tutorials I found some really great resources on the web as well as books. Unfortunately many of them were written for Spring 2.x, which lacks some recent features, mainly ability to configure everything by Java annotations (a.k.a. JavaConfig) rather than XML. That was something that kept me away from Spring at the first place - doing it programmatically gives much more sense of control and is more readable. So, that's what I'm trying to achieve here, I'll try to show you how to do it in more 'modern' way, showing integrations with various software packages along the way.

Setting Active Profile And Property Sources In Spring MVC

  • access_time 5 years ago
  • date_range 07/11/2013
  • comment 0
  • share 0
  • label_outlineSpring, Spring MVC

Update 12/2017: Just use Spring Boot profiles.

Often there are times when we need to access settings stored in property files depending on the environment we are in. For example database settings are likely to be different in development, testing and production environments. For this reason Spring offers a concept profile that appeared since version 3.1. That allows to selectively enable @Configuration classes for active profile thanks to @Profile annotation.