Category: java

Create simple project using Maven

Maven supports a simple mechanism to generate a project with the required structure and files already in place. Simply execute the command below:

mvn archetype:generate -DgroupId=com.test -DartifactId=mytest

Replace com.test and mytest with your preferred name and package for your project.

The maven documentation page contains a short list of the most common archtetypes. When you enter the command an interactive console will start from which you can select the preferred archetype to start with. You must enter the number of the archetype or you can specify a filter by packagename to shorten the list of options.

Leave a Comment

Spring autowire values in @Controller

The Java Spring framework allows you to annotate classes via the _@Controller _annotation. This allows you to maps requests and handle them via a MVC implementation. These classes can be detected automatically via a:

<context:component-scan base-package="example.class" />

The downside of this approach is that the values cannot be set anymore via a tag, because the class is already constructed. In order to still be able to set values in the class use the @Value annotation in the attribute fields of the class.

Leave a Comment