Can't resolve custom validation messages in Hibernate + Spring
<p>I am developing <code>Spring MVC + Hibernate Validator</code> integration example by taking reference from <a href="https://spring.io/guides/gs/validating-form-input/" rel="nofollow noreferrer">https://spring.io/guides/gs/validating-form-input/</a>. I added some messages to be gets resolved from <code>messages.properties</code> file, but none of the messages getting resolved and facing below issue. Please guide why application not recognizing the <code>messages.properties</code> file. I was expecting to get actual message from .properties file, but why this is coming <code>[{length.validation.country}]</code>?</p>

<pre><code>org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'person' on field 'country': rejected value [U]; 
codes [Length.person.country,Length.country,Length.java.lang.String,Length]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes 
[person.country,country]; arguments []; default message [country],50,2]; default message [{length.validation.country}]
</code></pre>

<p>Person.java</p>

<pre><code>@Entity
@Table(name="PERSON")
public class Person {

    @Id
    @Column(name="id")
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private int id;

    @SafeHtml(whitelistType=WhiteListType.NONE, message="{html.validation.firstname}")
    @Length(max=Constant.MAX_FIRSTNAME,min=Constant.MIN_FIRSTNAME,message="{length.validation.firstname}")
    @Column(name="FIRST_NAME")
    private String firstname;

    @SafeHtml(whitelistType=WhiteListType.NONE, message="{html.validation.lastname}")
    @Length(max=Constant.MAX_LASTNAME,min=Constant.MIN_LASTTNAME,message="{length.validation.lastname}")
    @Column(name="LAST_NAME")
    private String lastname;

    @SafeHtml(whitelistType=WhiteListType.NONE, message="{html.validation.country}")
    @Length(max=Constant.MAX_COUNTRY,min=Constant.MIN_COUNTRY,message="{length.validation.country}")
    @Column(name="COUNTRY")
    private String country;

    @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE, message = "{html.validation.emailId}")
    @Length(max=Constant.MAX_EMAILID,min=Constant.MIN_EMAILID, message = "{length.validation.emailId}")
    @Pattern(regexp = "^(.+)@(.+)$")
    @Column(name="EMAIL_ID")
    private String emailId;
        // setters and getters
}
</code></pre>

<p>PersonController.java</p>

<pre><code>@Controller
public class PersonController {

    private PersonService personService;

    public PersonController(){}

    public PersonController(PersonService personService){
        this.personService = personService;
    }

    @Autowired(required=true)
    @Qualifier(value="personService")
    public void setPersonService(PersonService ps){
        this.personService = ps;
    }

    @RequestMapping(value = "/persons", method = RequestMethod.GET)
    public String listPersons(Model model) {
        model.addAttribute("person", new Person());
        model.addAttribute("listPersons", this.personService.listPersons());
        return "person";
    }

    //For add and update person both
    @RequestMapping(value= "/person/add", method = RequestMethod.POST)
    public String addPerson(@Valid @ModelAttribute("person") Person p, BindingResult bindingResult){

        if(bindingResult.hasErrors()){
            System.out.println(bindingResult);
            return "redirect:/persons";
        }

        if(p.getId() == 0){
            //new person, add it
            this.personService.addPerson(p);
        }else{
            //existing person, call update
            this.personService.updatePerson(p);
        }

        return "redirect:/persons";

    }

    @RequestMapping("/remove/{id}")
    public String removePerson(@PathVariable("id") int id){
        this.personService.removePerson(id);
        return "redirect:/persons";
    }

    @RequestMapping("/edit/{id}")
    public String editPerson(@PathVariable("id") int id, Model model){
        model.addAttribute("person", this.personService.getPersonById(id));
        model.addAttribute("listPersons", this.personService.listPersons());
        return "person";
    }
}
</code></pre>

<p>messages.properties</p>

<pre><code>html.validation.firstName=Invalid First Name
length.validation.firstName=First Name should be 2 to 50 lenght in characters
html.validation.lastName=Invalid Last Name
length.validation.lastName=Last Name should be 2 to 50 lenght in characters
html.validation.country=Invalid Country Name
length.validation.country=Country Name should be 2 to 50 lenght in characters
html.validation.emailId=Invalid Email ID
length.validation.emailId=Email ID length should not be more than 11 characters
</code></pre>

<p>servlet-context.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;


    &lt;!-- Enables the Spring MVC @Controller programming model --&gt;
    &lt;annotation-driven /&gt;
    &lt;context:component-scan base-package="com.journaldev.spring.controller" /&gt;

    &lt;!-- Load database.properties file --&gt;
    &lt;context:property-placeholder location="classpath:database.properties" /&gt;

    &lt;!-- Enable JPA Repositories --&gt;
    &lt;jpa:repositories base-package="com.journaldev.spring.repository" /&gt;

    &lt;!-- Enable Transaction Manager --&gt;
    &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;

    &lt;!-- Necessary to get the entity manager injected into the factory bean --&gt;
    &lt;beans:bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /&gt;


    &lt;!-- ====== MYSQL DataSource ====== --&gt;
    &lt;beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
        &lt;beans:property name="driverClassName" value="${mysql.jdbc.driverClassName}" /&gt;
        &lt;beans:property name="url" value="${mysql.jdbc.url}" /&gt;
        &lt;beans:property name="username" value="${mysql.jdbc.userName}" /&gt;
        &lt;beans:property name="password" value="${mysql.jdbc.password}" /&gt;
    &lt;/beans:bean&gt;

    &lt;!-- ====== Hibernate JPA Vendor Adaptor ======= --&gt;
    &lt;beans:bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
        &lt;beans:property name="showSql" value="true"/&gt;
        &lt;beans:property name="generateDdl" value="true"/&gt;
        &lt;beans:property name="database" value="MYSQL"/&gt;
    &lt;/beans:bean&gt;


    &lt;!-- Beans --&gt;
    &lt;beans:bean id="personService" class="com.journaldev.spring.service.PersonServiceImpl" /&gt;
    &lt;beans:bean id="visitService" class="com.journaldev.spring.service.VisitServiceImpl" /&gt;


    &lt;beans:bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
        &lt;beans:property name="dataSource" ref="dataSource"/&gt;
        &lt;beans:property name="jpaVendorAdapter" ref="jpaVendorAdapter"/&gt;
        &lt;beans:property name="packagesToScan" value="com.journaldev.spring.*" /&gt;
        &lt;beans:property name="jpaProperties"&gt;
            &lt;beans:props&gt;
                &lt;beans:prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/beans:prop&gt;  &lt;!-- validate | update | create | create-drop --&gt;
                &lt;beans:prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/beans:prop&gt;
                &lt;!-- &lt;beans:prop key="hibernate.cache.use_query_cache"&gt;true&lt;/beans:prop&gt; --&gt; 
            &lt;/beans:props&gt;
        &lt;/beans:property&gt;
    &lt;/beans:bean&gt;

    &lt;beans:bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
        &lt;beans:property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
    &lt;/beans:bean&gt;

    &lt;beans:bean id="validationMessageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
        &lt;beans:property name="basename" value="classpath:messages" /&gt;
        &lt;beans:property name="defaultEncoding" value="UTF-8" /&gt;
    &lt;/beans:bean&gt;

    &lt;beans:bean name="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"&gt;
        &lt;beans:property name="validationMessageSource"&gt;
           &lt;beans:ref bean="validationMessageSource"/&gt;
        &lt;/beans:property&gt;
    &lt;/beans:bean&gt;
    &lt;beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
        &lt;beans:property name="prefix" value="/WEB-INF/views/" /&gt;
        &lt;beans:property name="suffix" value=".jsp" /&gt;
    &lt;/beans:bean&gt;
&lt;/beans:beans&gt;
</code></pre>

<p>Person.jsp</p>

<pre><code>&lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
&lt;%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %&gt;
&lt;%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %&gt;
&lt;%@ page session="false" %&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Person Details Page&lt;/title&gt;
    &lt;style type="text/css"&gt;
        .tg  {border-collapse:collapse;border-spacing:0;border-color:#ccc;}
        .tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ccc;color:#333;background-color:#fff;}
        .tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ccc;color:#333;background-color:#f0f0f0;}
        .tg .tg-4eph{background-color:#f9f9f9}
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;
    Add a Person
&lt;/h1&gt;

&lt;c:url var="addAction" value="/person/add" &gt;&lt;/c:url&gt;

&lt;form:form action="${addAction}" commandName="person"&gt;
&lt;table&gt;
    &lt;c:if test="${!empty person.firstname}"&gt;
    &lt;tr&gt;
        &lt;td&gt;
            &lt;form:label path="id"&gt;
                &lt;spring:message text="ID"/&gt;
            &lt;/form:label&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;form:input path="id" readonly="true" size="8"  disabled="true" /&gt;
            &lt;form:hidden path="id" /&gt;
        &lt;/td&gt; 
    &lt;/tr&gt;
    &lt;/c:if&gt;
    &lt;tr&gt;
        &lt;td&gt;
            &lt;form:label path="firstname"&gt;
                &lt;spring:message text="First Name"/&gt;
            &lt;/form:label&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;form:input path="firstname" /&gt;
        &lt;/td&gt; 
    &lt;/tr&gt;

    &lt;tr&gt;
        &lt;td&gt;
            &lt;form:label path="lastname"&gt;
                &lt;spring:message text="Last Name"/&gt;
            &lt;/form:label&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;form:input path="lastname" /&gt;
        &lt;/td&gt; 
    &lt;/tr&gt;

    &lt;tr&gt;
        &lt;td&gt;
            &lt;form:label path="emailId"&gt;
                &lt;spring:message text="EmailId"/&gt;
            &lt;/form:label&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;form:input path="emailId" /&gt;
        &lt;/td&gt; 
    &lt;/tr&gt;

    &lt;tr&gt;
        &lt;td&gt;
            &lt;form:label path="country"&gt;
                &lt;spring:message text="Country"/&gt;
            &lt;/form:label&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;form:input path="country" /&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td colspan="2"&gt;
            &lt;c:if test="${!empty person.firstname}"&gt;
                &lt;input type="submit"
                    value="&lt;spring:message text="Edit Person"/&gt;" /&gt;
            &lt;/c:if&gt;
            &lt;c:if test="${empty person.firstname}"&gt;
                &lt;input type="submit"
                    value="&lt;spring:message text="Add Person"/&gt;" /&gt;
            &lt;/c:if&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;    
&lt;/form:form&gt;
&lt;br&gt;
&lt;h3&gt;Persons List&lt;/h3&gt;
&lt;c:if test="${!empty listPersons}"&gt;
    &lt;table class="tg"&gt;
    &lt;tr&gt;
        &lt;th width="80"&gt;&lt;b&gt;PersonID&lt;/b&gt;&lt;/th&gt;
        &lt;th width="120"&gt;&lt;b&gt;FirstName&lt;/b&gt;&lt;/th&gt;
        &lt;th width="120"&gt;&lt;b&gt;LastName&lt;/b&gt;&lt;/th&gt;
        &lt;th width="120"&gt;&lt;b&gt;EmailID&lt;/b&gt;&lt;/th&gt;
        &lt;th width="120"&gt;&lt;b&gt;Country&lt;/b&gt;&lt;/th&gt;
        &lt;th width="60"&gt;&lt;b&gt;Edit&lt;/b&gt;&lt;/th&gt;
        &lt;th width="60"&gt;&lt;b&gt;Delete&lt;/b&gt;&lt;/th&gt;
    &lt;/tr&gt;
    &lt;c:forEach items="${listPersons}" var="person"&gt;
        &lt;tr&gt;
            &lt;td&gt;${person.id}&lt;/td&gt;
            &lt;td&gt;${person.firstname}&lt;/td&gt;
            &lt;td&gt;${person.lastname}&lt;/td&gt;
            &lt;td&gt;${person.emailId}&lt;/td&gt;
            &lt;td&gt;${person.country}&lt;/td&gt;
            &lt;td&gt;&lt;a href="&lt;c:url value='/edit/${person.id}' /&gt;" &gt;Edit&lt;/a&gt;&lt;/td&gt;
            &lt;td&gt;&lt;a href="&lt;c:url value='/remove/${person.id}' /&gt;" &gt;Delete&lt;/a&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/c:forEach&gt;
    &lt;/table&gt;
&lt;/c:if&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Image:
<a href="https://i.stack.imgur.com/fUtJr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fUtJr.png" alt="enter image description here"></a>
pom.xml</p>

<pre><code>&lt;properties&gt;
        &lt;java.version&gt;1.7&lt;/java.version&gt;
        &lt;org.springframework-version&gt;4.1.9.RELEASE&lt;/org.springframework-version&gt;
        &lt;org.aspectj-version&gt;1.7.4&lt;/org.aspectj-version&gt;
        &lt;org.slf4j-version&gt;1.7.5&lt;/org.slf4j-version&gt;
        &lt;hibernate.version&gt;5.1.0.Final&lt;/hibernate.version&gt;
        &lt;validation-api.version&gt;1.1.0.Final&lt;/validation-api.version&gt;
        &lt;hibernate-validator.version&gt;5.1.1.Final&lt;/hibernate-validator.version&gt;
        &lt;jsoup-version&gt;1.8.1&lt;/jsoup-version&gt;
        &lt;spring-data-jpa-version&gt;1.9.2.RELEASE&lt;/spring-data-jpa-version&gt;
    &lt;/properties&gt;

    &lt;dependencies&gt;
        &lt;!-- Spring --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
            &lt;version&gt;${org.springframework-version}&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
            &lt;version&gt;${org.springframework-version}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
            &lt;artifactId&gt;spring-data-jpa&lt;/artifactId&gt;
            &lt;version&gt;${spring-data-jpa-version}&lt;/version&gt;
        &lt;/dependency&gt;


        &lt;!-- Hibernate Entity Manager --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
            &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
            &lt;version&gt;${hibernate.version}&lt;/version&gt;
        &lt;/dependency&gt;


        &lt;!-- Validations --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;javax.validation&lt;/groupId&gt;
            &lt;artifactId&gt;validation-api&lt;/artifactId&gt;
            &lt;version&gt;${validation-api.version}&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
            &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
            &lt;version&gt;${hibernate-validator.version}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;!-- Apache Commons DBCP --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
            &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
            &lt;version&gt;1.4&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;!-- Spring ORM --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
            &lt;version&gt;${org.springframework-version}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
            &lt;version&gt;${org.springframework-version}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;!-- Querydsl dependencies --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.mysema.querydsl&lt;/groupId&gt;
            &lt;artifactId&gt;querydsl-core&lt;/artifactId&gt;
            &lt;version&gt;3.3.2&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.mysema.querydsl&lt;/groupId&gt;
            &lt;artifactId&gt;querydsl-apt&lt;/artifactId&gt;
            &lt;version&gt;3.3.2&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.mysema.querydsl&lt;/groupId&gt;
            &lt;artifactId&gt;querydsl-jpa&lt;/artifactId&gt;
            &lt;version&gt;3.3.2&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;!-- LOG4J --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;log4j&lt;/groupId&gt;
            &lt;artifactId&gt;log4j&lt;/artifactId&gt;
            &lt;version&gt;1.2.17&lt;/version&gt;
            &lt;scope&gt;runtime&lt;/scope&gt;
        &lt;/dependency&gt;


        &lt;!-- Needed for Hibernate Validation --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.jsoup&lt;/groupId&gt;
            &lt;artifactId&gt;jsoup&lt;/artifactId&gt;
            &lt;version&gt;${jsoup-version}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;com.google.code.findbugs&lt;/groupId&gt;
            &lt;artifactId&gt;jsr305&lt;/artifactId&gt;
            &lt;version&gt;3.0.0&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;!-- @Inject --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;javax.inject&lt;/groupId&gt;
            &lt;artifactId&gt;javax.inject&lt;/artifactId&gt;
            &lt;version&gt;1&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;!-- JSP API --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
            &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
            &lt;version&gt;2.1&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;!-- Servlet API --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
            &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
            &lt;version&gt;2.5&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;

        &lt;!-- JSTL --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
            &lt;artifactId&gt;jstl&lt;/artifactId&gt;
            &lt;version&gt;1.2&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;!-- Junit Test --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;junit&lt;/groupId&gt;
            &lt;artifactId&gt;junit&lt;/artifactId&gt;
            &lt;version&gt;4.12&lt;/version&gt;
            &lt;scope&gt;test&lt;/scope&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;mysql&lt;/groupId&gt;
            &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
            &lt;version&gt;5.1.37&lt;/version&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;

    &lt;!-- Project Build --&gt;
    &lt;build&gt;
        &lt;finalName&gt;spring-mvc-jpa-hibernate&lt;/finalName&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                &lt;version&gt;2.5.1&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;source&gt;${java.version}&lt;/source&gt;
                    &lt;target&gt;${java.version}&lt;/target&gt;
                    &lt;compilerArgument&gt;-Xlint:all&lt;/compilerArgument&gt;
                    &lt;showWarnings&gt;true&lt;/showWarnings&gt;
                    &lt;showDeprecation&gt;true&lt;/showDeprecation&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;


            &lt;plugin&gt;
                &lt;groupId&gt;com.mysema.maven&lt;/groupId&gt;
                &lt;artifactId&gt;apt-maven-plugin&lt;/artifactId&gt;
                &lt;version&gt;1.1.1&lt;/version&gt;
                &lt;executions&gt;
                    &lt;execution&gt;
                        &lt;phase&gt;generate-sources&lt;/phase&gt;
                        &lt;goals&gt;
                            &lt;goal&gt;process&lt;/goal&gt;
                        &lt;/goals&gt;
                        &lt;configuration&gt;
                            &lt;!-- Specifies the directory in which the query types are generated --&gt;
                            &lt;outputDirectory&gt;target/generated-sources&lt;/outputDirectory&gt;
                            &lt;!-- States that the APT code generator should look for JPA annotations --&gt;
                            &lt;processor&gt;com.mysema.query.apt.jpa.JPAAnnotationProcessor&lt;/processor&gt;
                        &lt;/configuration&gt;
                    &lt;/execution&gt;
                &lt;/executions&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
    &lt;/build&gt;
</code></pre>