BAEL-2985 fix Spring Boot apps in spring-data-rest (#7224)

* BAEL-2246: add link back to article

* BAEL-2174: rename core-java-net module to core-java-networking

* BAEL-2174: add link back to article

* BAEL-2363 BAEL-2337 BAEL-1996 BAEL-2277 add links back to articles

* BAEL-2367: add link back to article

* BAEL-2335: add link back to article

* BAEL-2413: add link back to article

* Update README.MD

* BAEL-2577: add link back to article

* BAEL-2490: add link back to article

* BAEL-2471: add link back to article

* BAEL-2583: add link back to article

* BAEL-2738: add link back to article

* BAEL-2711: Add spring-boot-angular module to root pom

* BAEL-2544 BAEL-2711 BAEL-2575 BAEL-2657 Add links back to articles

* BAEL-2736: Add link back to article

* BAEL-2789: Add link back to article

* BAEL-2489: add link back to article

* BAEL-2840: add link back to article

* BAEL-2655: add link back to article

* BAEL-2884: add link back to article

* BAEL-2985: Fix Spring Boot Apps in spring-data-rest module
This commit is contained in:
KevinGilmore 2019-06-30 16:27:50 -05:00 committed by GitHub
parent 81358eefbb
commit a79e249b61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 71 additions and 60 deletions

View File

@ -1,4 +1,4 @@
package com.baeldung;
package com.baeldung.books;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -1,4 +1,4 @@
package com.baeldung.config;
package com.baeldung.books.config;
import java.util.Properties;
@ -16,7 +16,7 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
@Configuration
@EnableJpaRepositories(basePackages = "com.baeldung.repositories")
@EnableJpaRepositories(basePackages = "com.baeldung.books.repositories")
// @PropertySource("persistence-h2.properties")
// @PropertySource("persistence-hsqldb.properties")
// @PropertySource("persistence-derby.properties")
@ -40,7 +40,7 @@ public class DbConfig {
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan(new String[] { "com.baeldung.models" });
em.setPackagesToScan(new String[] { "com.baeldung.books.models" });
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setJpaProperties(additionalProperties());
return em;

View File

@ -1,13 +1,14 @@
package com.baeldung.config;
package com.baeldung.books.config;
import com.baeldung.events.AuthorEventHandler;
import com.baeldung.events.BookEventHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.baeldung.books.events.AuthorEventHandler;
import com.baeldung.books.events.BookEventHandler;
@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {

View File

@ -1,7 +1,8 @@
package com.baeldung.config;
package com.baeldung.books.config;
import com.baeldung.books.models.WebsiteUser;
import com.baeldung.books.projections.CustomBook;
import com.baeldung.models.WebsiteUser;
import com.baeldung.projections.CustomBook;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.core.mapping.ExposureConfiguration;

View File

@ -1,4 +1,4 @@
package com.baeldung.config;
package com.baeldung.books.config;
import java.util.Arrays;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.baeldung.dialect;
package com.baeldung.books.dialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.identity.IdentityColumnSupport;

View File

@ -1,4 +1,4 @@
package com.baeldung.dialect;
package com.baeldung.books.dialect;
import org.hibernate.MappingException;
import org.hibernate.dialect.identity.IdentityColumnSupportImpl;

View File

@ -1,9 +1,10 @@
package com.baeldung.events;
package com.baeldung.books.events;
import com.baeldung.models.Author;
import com.baeldung.models.Book;
import org.springframework.data.rest.core.annotation.*;
import com.baeldung.books.models.Author;
import com.baeldung.books.models.Book;
import java.util.logging.Logger;
@RepositoryEventHandler

View File

@ -1,13 +1,15 @@
package com.baeldung.events;
package com.baeldung.books.events;
import java.util.logging.Logger;
import com.baeldung.models.Author;
import com.baeldung.models.Book;
import org.apache.commons.logging.Log;
import org.springframework.data.rest.core.annotation.HandleAfterDelete;
import org.springframework.data.rest.core.annotation.HandleBeforeCreate;
import org.springframework.data.rest.core.annotation.RepositoryEventHandler;
import com.baeldung.books.models.Author;
import com.baeldung.books.models.Book;
@RepositoryEventHandler
public class BookEventHandler {
Logger logger = Logger.getLogger("Class BookEventHandler");

View File

@ -1,4 +1,4 @@
package com.baeldung.exception.handlers;
package com.baeldung.books.exception.handlers;
import org.springframework.data.rest.core.RepositoryConstraintViolationException;
import org.springframework.http.HttpHeaders;

View File

@ -1,4 +1,4 @@
package com.baeldung.models;
package com.baeldung.books.models;
import javax.persistence.Column;
import javax.persistence.Entity;

View File

@ -1,4 +1,4 @@
package com.baeldung.models;
package com.baeldung.books.models;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.baeldung.models;
package com.baeldung.books.models;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.baeldung.models;
package com.baeldung.books.models;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.baeldung.models;
package com.baeldung.books.models;
import javax.persistence.Column;
import javax.persistence.Entity;

View File

@ -1,4 +1,4 @@
package com.baeldung.models;
package com.baeldung.books.models;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;

View File

@ -1,12 +1,12 @@
package com.baeldung.projections;
package com.baeldung.books.projections;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.rest.core.config.Projection;
import com.baeldung.models.Author;
import com.baeldung.models.Book;
import com.baeldung.books.models.Author;
import com.baeldung.books.models.Book;
@Projection(name = "customBook", types = { Book.class })
public interface CustomBook {

View File

@ -1,8 +1,8 @@
package com.baeldung.repositories;
package com.baeldung.books.repositories;
import org.springframework.data.repository.CrudRepository;
import com.baeldung.models.Address;
import com.baeldung.books.models.Address;
public interface AddressRepository extends CrudRepository<Address, Long> {

View File

@ -1,8 +1,8 @@
package com.baeldung.repositories;
package com.baeldung.books.repositories;
import org.springframework.data.repository.CrudRepository;
import com.baeldung.models.Author;
import com.baeldung.books.models.Author;
public interface AuthorRepository extends CrudRepository<Author, Long> {

View File

@ -1,10 +1,10 @@
package com.baeldung.repositories;
package com.baeldung.books.repositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import com.baeldung.models.Book;
import com.baeldung.projections.CustomBook;
import com.baeldung.books.models.Book;
import com.baeldung.books.projections.CustomBook;
@RepositoryRestResource(excerptProjection = CustomBook.class)
public interface BookRepository extends CrudRepository<Book, Long> {

View File

@ -1,8 +1,8 @@
package com.baeldung.repositories;
package com.baeldung.books.repositories;
import org.springframework.data.repository.CrudRepository;
import com.baeldung.models.Library;
import com.baeldung.books.models.Library;
public interface LibraryRepository extends CrudRepository<Library, Long> {

View File

@ -1,11 +1,12 @@
package com.baeldung.repositories;
package com.baeldung.books.repositories;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;
import com.baeldung.models.Subject;
import com.baeldung.books.models.Subject;
public interface SubjectRepository extends PagingAndSortingRepository<Subject, Long> {

View File

@ -1,11 +1,12 @@
package com.baeldung.repositories;
package com.baeldung.books.repositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.data.rest.core.annotation.RestResource;
import org.springframework.web.bind.annotation.CrossOrigin;
import com.baeldung.models.WebsiteUser;
import com.baeldung.books.models.WebsiteUser;
@CrossOrigin
@RepositoryRestResource(collectionResourceRel = "users", path = "users")

View File

@ -1,10 +1,10 @@
package com.baeldung.validators;
package com.baeldung.books.validators;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
import com.baeldung.models.WebsiteUser;
import com.baeldung.books.models.WebsiteUser;
@Component("beforeCreateWebsiteUserValidator")
public class WebsiteUserValidator implements Validator {

View File

@ -1,6 +1,8 @@
package com.baeldung.events;
package com.baeldung.books.events;
import com.baeldung.books.events.AuthorEventHandler;
import com.baeldung.books.models.Author;
import com.baeldung.models.Author;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.data.rest.core.annotation.RepositoryEventHandler;

View File

@ -1,7 +1,9 @@
package com.baeldung.events;
package com.baeldung.books.events;
import com.baeldung.books.events.BookEventHandler;
import com.baeldung.books.models.Author;
import com.baeldung.books.models.Book;
import com.baeldung.models.Author;
import com.baeldung.models.Book;
import org.junit.Test;
import org.mockito.Mockito;

View File

@ -1,4 +1,4 @@
package com.baeldung.projection;
package com.baeldung.books.projections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -16,11 +16,11 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.SpringDataRestApplication;
import com.baeldung.models.Author;
import com.baeldung.models.Book;
import com.baeldung.repositories.AuthorRepository;
import com.baeldung.repositories.BookRepository;
import com.baeldung.books.SpringDataRestApplication;
import com.baeldung.books.models.Author;
import com.baeldung.books.models.Book;
import com.baeldung.books.repositories.AuthorRepository;
import com.baeldung.books.repositories.BookRepository;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringDataRestApplication.class, webEnvironment = WebEnvironment.DEFINED_PORT)

View File

@ -1,4 +1,4 @@
package com.baeldung.validator;
package com.baeldung.books.validator;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
@ -19,8 +19,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.context.WebApplicationContext;
import com.baeldung.SpringDataRestApplication;
import com.baeldung.models.WebsiteUser;
import com.baeldung.books.SpringDataRestApplication;
import com.baeldung.books.models.WebsiteUser;
import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(SpringJUnit4ClassRunner.class)

View File

@ -42,7 +42,7 @@ public class UserControllerIntegrationTest {
@Test
public void whenGetRequestToUserEndPointWithNameRequestParameter_thenCorrectResponse() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/user").param("name", "John").contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(MockMvcResultMatchers.status().isOk())
mockMvc.perform(MockMvcRequestBuilders.get("/users").param("name", "John").contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$['content'][0].['name']").value("John"));
}

View File

@ -5,7 +5,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.SpringDataRestApplication;
import com.baeldung.books.SpringDataRestApplication;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringDataRestApplication.class)