Fixed issues due to parent-boot-2 migration (migration to Spring-boot 2):

* Configured Hiberante 5 correctly
* Configured Git plugin correctly
* Changed hibernate methods to comply with new method naming conventions
* Removed and replaced deprecated properties
* Updated Actuator test to use new response structure
* Using random port in Mongo integration test, to avoid clashing with a potential instance using the mongo default port
This commit is contained in:
geroza
2018-11-16 14:34:48 -02:00
parent 42fac5dbcf
commit 47735dcd70
20 changed files with 109 additions and 65 deletions
@@ -30,7 +30,7 @@ public class ContactInfoValidator implements ConstraintValidator<ContactInfo, St
if (StringUtils.isEmptyOrWhitespace(expressionType)) {
LOG.error("Contact info type missing!");
} else {
pattern = expressionRepository.findOne(expressionType).map(ContactInfoExpression::getPattern).orElse("");
pattern = expressionRepository.findById(expressionType).map(ContactInfoExpression::getPattern).orElse("");
}
}
@@ -9,7 +9,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
public class DynamicValidationApp {
@RolesAllowed("*")
public static void main(String[] args) {
System.setProperty("security.basic.enabled", "false");
SpringApplication.run(DynamicValidationApp.class, args);
}
}
@@ -7,5 +7,5 @@ import org.springframework.data.repository.Repository;
import com.baeldung.dynamicvalidation.model.ContactInfoExpression;
public interface ContactInfoExpressionRepository extends Repository<ContactInfoExpression, String> {
Optional<ContactInfoExpression> findOne(String id);
Optional<ContactInfoExpression> findById(String id);
}
@@ -9,7 +9,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
public class FailureAnalyzerApplication {
@RolesAllowed("*")
public static void main(String[] args) {
System.setProperty("security.basic.enabled", "false");
SpringApplication.run(FailureAnalyzerApplication.class, args);
}
}
@@ -9,7 +9,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
public class InternationalizationApp {
@RolesAllowed("*")
public static void main(String[] args) {
System.setProperty("security.basic.enabled", "false");
SpringApplication.run(InternationalizationApp.class, args);
}
}
@@ -1,18 +1,17 @@
package com.baeldung.rss;
import javax.annotation.security.RolesAllowed;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import javax.annotation.security.RolesAllowed;
@SpringBootApplication
@ComponentScan(basePackages = "com.baeldung.rss")
public class RssApp {
@RolesAllowed("*")
public static void main(String[] args) {
System.setProperty("security.basic.enabled", "false");
SpringApplication.run(RssApp.class, args);
}
@@ -9,7 +9,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
public class ToggleApplication {
@RolesAllowed("*")
public static void main(String[] args) {
System.setProperty("security.basic.enabled", "false");
SpringApplication.run(ToggleApplication.class, args);
}
}
@@ -4,8 +4,6 @@ import org.baeldung.demo.model.Foo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.orm.jpa.vendor.HibernateJpaSessionFactoryBean;
@EntityScan(basePackageClasses = Foo.class)
@SpringBootApplication
@@ -15,9 +13,4 @@ public class Application {
System.setProperty("spring.profiles.active", "exception");
SpringApplication.run(Application.class, args);
}
@Bean
public HibernateJpaSessionFactoryBean sessionFactory() {
return new HibernateJpaSessionFactoryBean();
}
}
@@ -1,5 +1,7 @@
package org.baeldung.session.exception.repository;
import javax.persistence.EntityManagerFactory;
import org.baeldung.demo.model.Foo;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -10,16 +12,15 @@ import org.springframework.stereotype.Repository;
@Repository
public class FooRepositoryImpl implements FooRepository {
@Autowired
private SessionFactory sessionFactory;
private EntityManagerFactory emf;
@Override
public void save(Foo foo) {
sessionFactory.getCurrentSession().saveOrUpdate(foo);
emf.unwrap(SessionFactory.class).getCurrentSession().saveOrUpdate(foo);
}
@Override
public Foo get(Integer id) {
return sessionFactory.getCurrentSession().get(Foo.class, id);
return emf.unwrap(SessionFactory.class).getCurrentSession().get(Foo.class, id);
}
}