I have a Spring Boot 1.4 app, which I'm trying to use Eclipselink instead Hibernate.
For now, this is what I did:
Removed Hibernate from deps
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
</exclusions>
</dependency>
Added eclipselink
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.3</version>
</dependency>
Configured JpaBaseConfiguration
#Configuration
public class JpaConfiguration extends JpaBaseConfiguration {
protected JpaConfiguration(DataSource dataSource, JpaProperties properties, ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider) {
super(dataSource, properties, jtaTransactionManagerProvider);
}
#Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(final EntityManagerFactoryBuilder builder, #Autowired DataSource dataSource) {
final LocalContainerEntityManagerFactoryBean ret = builder.dataSource(dataSource)
.packages("com.inkdrop.app.domain.models")
.persistenceUnit("chathub-perstence-unit")
.properties(getVendorProperties())
.build();
return ret;
}
#Override
protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
return new EclipseLinkJpaVendorAdapter();
}
#Override
protected Map<String, Object> getVendorProperties() {
return Collections.singletonMap("eclipselink.weaving", "false");
}
when I run the app, it creates the tables in database (representing my models), and then, throws this error:
Caused by: java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.metamodel.SingularAttributeImpl cannot be cast to javax.persistence.metamodel.PluralAttribute
at org.eclipse.persistence.internal.jpa.querydef.FromImpl.join(FromImpl.java:485)
at org.springframework.data.jpa.repository.query.QueryUtils.getOrCreateJoin(QueryUtils.java:596)
at org.springframework.data.jpa.repository.query.QueryUtils.toExpressionRecursively(QueryUtils.java:524)
at org.springframework.data.jpa.repository.query.JpaQueryCreator$PredicateBuilder.getTypedPath(JpaQueryCreator.java:332)
at org.springframework.data.jpa.repository.query.JpaQueryCreator$PredicateBuilder.build(JpaQueryCreator.java:275)
at org.springframework.data.jpa.repository.query.JpaQueryCreator.toPredicate(JpaQueryCreator.java:180)
at org.springframework.data.jpa.repository.query.JpaQueryCreator.create(JpaQueryCreator.java:109)
at org.springframework.data.jpa.repository.query.JpaQueryCreator.create(JpaQueryCreator.java:49)
at org.springframework.data.repository.query.parser.AbstractQueryCreator.createCriteria(AbstractQueryCreator.java:109)
at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:88)
at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:73)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$QueryPreparer.<init>(PartTreeJpaQuery.java:118)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$CountQueryPreparer.<init>(PartTreeJpaQuery.java:241)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:68)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:103)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:214)
I tried following this and this tutorials, but didn't helped
I think that your problem is an incompatibility between Spring Data version and the EclipseLink version that you use.
Eclipselink support in SpringBoot seems bad.
In the pom.xml of spring-boot-dependencies :
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.4.0.RELEASE</version>
in properties tags, you can see :
<properties>
...
<hibernate.version>5.0.9.Final</hibernate.version>
<hibernate-validator.version>5.2.4.Final</hibernate-validator.version>
...
</properties>
but zero information about Eclipselink.
In the same way, in the spring-boot-starter-data-jpa pom, you have a direct dependency for hibernate-core in dependencies tag :
<dependencies>
...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
...
<dependencies>
but no dependency for EclipseLink in dependenciesManagement tag. It's a pity since it could have given a way, for projets to use on demand a EclipseLink version compatible with current Spring Boot version in this way :
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
</dependency>
But as this feature is missing, you must specify the version of Eclipslink in your pom.xml :
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.3</version>
</dependency>
In your case, it may be complicated to guess which version of Eclipselink is compatible with the 1.4 spring boot version since your tutorial use the 1.3.2 spring boot version.
To address your problem, I advise you to try with the same versions (EclipseLink and Spring Boot) as in your tutorial or any working application using SpringBoot and EclipseLink to check that it's well a version compatibility problem.
If it's ok, then and if you want to update your Spring Boot or EclipseLink version or both, you must do tests to validate a winning combination between Spring Boot, and EclipseLink versions.
Related
I have springboot (2.0.4) application with Mongo Java driver version 3.11.2. When upgrading the application for mongo java driver to version 4.1.0 to use IAM authentication feature of new mongo java driver, the changes are breaking with overall spring framework.
MongoTemplate Bean code:
#Bean
public MongoClient mongoClient() {
ConnectionString connectionString = new ConnectionString(
("mongodb://connectionString:goesHere"));
MongoClient mongoClient = MongoClients.create(connectionString);
return mongoClient;
}
#Bean
public MongoTemplate mongoTemplate(MongoClient mongoClient) {
return new MongoTemplate(mongoClient, mongoDB);
}
Dependencies:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-core</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</exclusion>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</exclusion>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
</exclusion>
</exclusions>
</dependecy>
Deployment error with Mongo Java Driver 4.1.0:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.MongoTemplate]: Factory method 'mongoTemplate' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.util.Assert.noNullElements(Ljava/util/Collection;Ljava/lang/String;)V
When looking into this issue, found that I need to add sping-core (5.2.5 or later) for this, that in turn is asking for other spring dependencies to be on same version.
This whole defeats the goal of having spring boot for ease of dependency management.
It feels like spring ecosystem has become so complex, that upgrading mongo-java-driver would need the un-necessary work of upgrading the whole application to newer version of springboot which are not backward compatible and will break the application build. Any suggestions to get rid of this issue.
i'm using these pom you can give it a try for mongo-3.8.2 and spring-data :1.10.0
. Make sure you are not missing "spring-data-commons-core jar"
<properties>
<mongo.java.driver.version>3.8.2</mongo.java.driver.version>
<spring.data.version>1.10.0.RELEASE</spring.data.version>
</properties>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>${mongo.java.driver.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons-core</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>${spring.data.version}</version>
</dependency>
I am using Spring batch to load data into gemfire using
#Bean
public GemfireTemplate gemFireTemplate(ClientRegionFactory<Object,
Object> factory) {
GemfireTemplate template = new GemfireTemplate();
template.setRegion("regionName");
return template;
}
POM:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-gemfire</artifactId>
<version>1.5.16.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-geode</artifactId>
<version>2.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>io.pivotal.gemfire</groupId>
<artifactId>geode-core</artifactId>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.pivotal.gemfire</groupId>
<artifactId>geode-common</artifactId>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.pivotal.gemfire</groupId>
<artifactId>geode-cq</artifactId>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.pivotal.gemfire</groupId>
<artifactId>geode-wan</artifactId>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.pivotal.gemfire</groupId>
<artifactId>geode-json</artifactId>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.pivotal.gemfire</groupId>
<artifactId>geode-lucene</artifactId>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.2.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.2.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.0.3.RELEASE</version>
</dependency>
Logs :
[info 2019/09/11 22:29:22.836 CDT <main> tid=0x1] GemFireCache[id = 892555958; isClosing = true; isShutDownAll = false; created = Wed Sep 11 22:29:20 CDT 2019; server = false; copyOnRead = false; lockLease = 120; lockTimeout = 60]: Now closing.
[error 2019/09/11 22:29:22.913 CDT <main> tid=0x1] java.lang.RuntimeException: java.io.IOException: Unable to write to deploy directory: /data/khan/vaquar/dataloader
java.lang.RuntimeException: java.io.IOException: Unable to write to deploy directory: /data/khan/vaquar/dataloader
at org.apache.geode.internal.JarDeployer.loadPreviouslyDeployedJarsFromDisk(JarDeployer.java:410)
at org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1191)
at org.apache.geode.internal.cache.GemFireCacheImpl.basicCreate(GemFireCacheImpl.java:758)
at org.apache.geode.internal.cache.GemFireCacheImpl.createClient(GemFireCacheImpl.java:731)
at org.apache.geode.cache.client.ClientCacheFactory.basicCreate(ClientCacheFactory.java:262)
at org.apache.geode.cache.client.ClientCacheFactory.create(ClientCacheFactory.java:212)
at com.syf.gemfire.jdbc.dataloader.config.FullBatchConf.clientCache(FullBatchConf.java:205)
at com.syf.gemfire.jdbc.dataloader.config.FullBatchConf$$EnhancerBySpringCGLIB$$749d49c1.CGLIB$clientCache$5(<generated>)
at com.syf.gemfire.jdbc.dataloader.config.FullBatchConf$$EnhancerBySpringCGLIB$$749d49c1$$Fast
Caused by: java.io.IOException: Unable to write to deploy directory: /data/khan/vaquar/dataloader
at org.apache.geode.internal.JarDeployer.verifyWritableDeployDirectory(JarDeployer.java:333)
at org.apache.geode.internal.JarDeployer.loadPreviouslyDeployedJarsFromDisk(JarDeployer.java:389)
and
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.geode.cache.client.ClientCache]: Factory method 'clientCache' threw exception; nested exception is java.lang.RuntimeException: java.io.IOException: Unable to write to deploy directory:/data/khan/vaquar/dataloader
Analysis:
Pivotal jars required write permissions when start geode connection with gemfire cluster .
Pivotal code :
https://github.com/ashishtadose/gemfire-xd/blob/master/gemfire-core/src/main/java/com/gemstone/gemfire/internal/JarDeployer.java
Pivotal Doc:
- https://gemfire.docs.pivotal.io/98/geode/configuring/cluster_config/deploying_application_jars.html
If gemfire.properties is specified then Geode locator fails to start
https://www.mail-archive.com/issues#geode.apache.org/msg17105.html
https://issues.apache.org/jira/browse/GEODE-5000?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel
Pivotal doc says if we can remove "deploy-working-dir"inside "gefire.properties" will resolve issue else use "-Dgemfire.deploy-working-dir=/temp/
Problem :
inside Spring batch we are not configuring any gemfire properties , how to fix it in GemfireTemplate code ?
The issue is clearly the same as the one described by the Geode Ticket you attached to the question, GEODE-5000. This particular ticket is fixed in Geode 1.6.0 and, according to the Pivotal GemFire User Guide, specifically the Release Notes, GemFire 9.5 is based on Geode 1.6.0, so you should be using that version instead of 9.3.0 to get rid of the problem.
As a side note, you shouldn't be arbitrarily mixing and matching spring-data-gemfire and gemfire versions as several issues might rise, please follow the Spring Data for Pivotal GemFire Version Compatibility Matrix to avoid issues.
Hope this helps. Cheers.
I'm working on a set of integration tests using arquillian and dbunit. I can run some of my tests just fine, but not the ones involving entities which have oneToMany relations with data in them. When running my tests I then get a PersistenceException:
Caused by: java.lang.NullPointerException
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.setInverseRelation(JDBCStoreManager.java:451)
My test looks like this:
#RunWith(Arquillian.class)
#CreateSchema("sql/masterplanCreateTables.sql")
public class MasterPlanManagerBeanDbIT {
#Rule
public PersistenceUnitRule rule = new PersistenceUnitRule();
#Inject
private MasterplanManager instance;
#PersistenceContext
EntityManager entityManager;
#Deployment
public static WebArchive createDeployment() throws Exception {
return ShrinkWrap
.create(WebArchive.class, .....
}
#Test
#UsingDataSet("/data/integration/uttrans/masterplan/validData_dbInput.xml")
public void updateTrip_givenValidInput_expectsTripToBeUpdated() {
Trip input = givenTrips().get(0);
input.setNote("updated value");
Trip updated = instance.updateTrip(input);
checkEquality(input, updated);//checks field by field for equality
}
}
My pom.xml looks like this:
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.0.1.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
...
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>arquillian-tomee-embedded</artifactId>
<version>${tomee.version}</version>
<scope>test</scope>
</dependency>
...
</dependencies>
...
I did try the openjpa-maven-plugin to enhance the entities at build-time, but this will afaik alter the compiled entities which later will be deployed to our production environment (using deploy-time enhancement).
With that in mind, is it possible to enable deploy-time enhancement in my arquillian tests?
As I'm using openJpa, I found this link very helpful:
http://openejb.apache.org/javaagent.html
I am simply providing the openejb java-agent to the maven surefire plugin.
If you are using eclipse add -javaagent:{your java agent path} to the VM arguments for the test.
In my case I took the java agent directly from a TomEE installation.
I'm actually trying to deploy HibernateSearch in a J2EE application. I have imported some dependencies I've seen on tuto's :
<!-- HIBERNATE DEPENDENCIES -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>${commons-dbcp.version}</version>
</dependency>
<!-- Hibernate Search -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
<version>3.1.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers</artifactId>
<version>3.0.3</version>
</dependency>
My problem is, in order to continue, I need to put the #Indexed annotation in my entity classes but I don't have access to this annotation(Eclipse doesn't know it and of course,that doesn't pass the compilation)
Could you give me some advice or lead ? Maybe I don't have the good dependencies ?
I don't use Eclipse or Maven but I can confirm that in my project that uses Hibernate Search 3.3.0 that the Indexed annotation does definitely exist in the hibernate-search-3.3.0.Final JAR. Try update your dependencies to use the latest JAR. There is definitely nothing else that you need to use this annotation though.
I'm trying to add constraints checking, as described here How to specify the cardinality of a #OneToMany in EclipseLink/JPA
Here are the dependencies I'm using (with Maven):
<dependencies>
<!-- Bean Validation API and RI -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.0.2.GA</version>
</dependency>
</dependencies>
That you can get from this repository:
<repositories>
<repository>
<id>jboss</id>
<name>JBoss repository</name>
<url>http://repository.jboss.org/maven2</url>
</repository>
</repositories>
The dependencies as of 2019:
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.16.Final</version>
</dependency>
This transitively pulls in the dependency to the Bean Validation API, so you don't need to do this anymore:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
For additional features, Expression Language and CDI support, you might need to add:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b09</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator-cdi</artifactId>
<version>6.0.16.Final</version>
</dependency>
Source: Hibernate Validator documentation
These are all in Maven Central Repo, so you don't need to add the JBoss repo.
And BTW here's my example convenience method:
public static <T extends Object> void validate( T object ) throws MigrationException
{
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<T>> valRes = validator.validate( object );
if( ! valRes.isEmpty() )
{
StringBuilder sb = new StringBuilder("Validation failed for: ");
if( object instanceof Origin.Wise )
sb.append( ((Origin.Wise)object).getOrigin() );
else
sb.append(object);
for( ConstraintViolation<T> fail : valRes)
{
sb.append("\n ").append( fail.getMessage() );
}
throw new IllegalArgumentException( sb.toString() );
}
}
The Origin.Wise is something like JAXB's #XmlLocation Locator.
In 2013 (the original post) the versions were:
<!-- BeanValidation and Hibernate Validator. -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b08</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-cdi</artifactId>
<version>5.4.0.Final</version>
</dependency>
An alternative solution other than Hibernate
Overview
javax.validation (validation-api) is validation rules that follows JSR 380 Java Bean Validation Specification. The validation rules need a validator in order to perform validating according to the validation rules.
And there are various validators such as hibernate (the most popular one), Bval, etc.
Bval
Bval is an alternative solution that I think It pretty cool also besides Hibernate. And here you can follow my alternative solution:
MVN
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.apache.bval</groupId>
<artifactId>bval-jsr</artifactId>
<version>2.0.2</version>
</dependency>
Implementation
create static a validator
...
import javax.validation.Validation;
import javax.validation.Validator;
import org.apache.bval.jsr.ApacheValidationProvider;
...
private static final Validator validator;
static {
validator = Validation.byProvider(ApacheValidationProvider.class).configure().buildValidatorFactory()
.getValidator();
}
There you go!!!.
Again, validator, it is just a validator, in which you switch to other validators easily.
Pro&Con
It is not that popular, but You gonna like it.
For Maven projects only is necessary use this dependency for validation annotations:
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.16.Final</version>
</dependency>
If you are using spring boot you can add the following dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>