The import org.hibernate.validator.Length cannot be resolved?

Here is my pom:

<dependencies>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>2.3.16</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.9</version>
        </dependency>

        <dependency>
            <groupId>com.google.code</groupId>
            <artifactId>struts2-fullhibernatecore-plugin</artifactId>
            <version>2.2.2-GA</version>
        </dependency>

         <!-- validation -->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.2.0.Final</version>
        </dependency>
        <!-- for annotations like @Entity,@Table -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.4.0.GA</version>
        </dependency>

        <!-- dependencies of hibernate-core -->
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

How to resolve this error :

The import org.hibernate.validator.Length cannot be resolved

Edit :

[ERROR]   symbol:   class Length
  location: class User

Thank you!

Answers


You seem to be missing the constraints package name in your code

import org.hibernate.validator.constraints.Length;

Since you have the hibernate-validator dependency set, you will have to run

mvn clean install 

in order to get it added to the classpath.


Need Your Help

protocol buffers : no notation for fixed size buffers?

c++ protocol-buffers file-format

Since I am not getting an answer on this question I gotta prototype and check myself, as my dataset headers need to be fixed size, I need fixed size strings. So, is it possible to specify fixed size

How to enforce custom MySQL column format

mysql regex

What if I wanted to define a custom column format in MySQL? The custom format that I want is always a 2 digit integer, followed by the # sign, then a space, then a decimal number with 2 digits aft...