diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml
index decaccd148..2bf7c0181f 100644
--- a/spring-boot-rest/pom.xml
+++ b/spring-boot-rest/pom.xml
@@ -63,6 +63,11 @@
htmlunit
test
+
+ org.modelmapper
+ modelmapper
+ ${modelmapper.version}
+
@@ -78,5 +83,6 @@
com.baeldung.SpringBootRestApplication
27.0.1-jre
1.4.11.1
+ 2.3.3
diff --git a/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java b/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java
index 62aae7619d..1c0d0d19e8 100644
--- a/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java
+++ b/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java
@@ -1,7 +1,9 @@
package com.baeldung;
+import org.modelmapper.ModelMapper;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class SpringBootRestApplication {
@@ -9,5 +11,10 @@ public class SpringBootRestApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootRestApplication.class, args);
}
+
+ @Bean
+ public ModelMapper modelMapper() {
+ return new ModelMapper();
+ }
}
diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/controller/PostRestController.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/controller/PostRestController.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/modelmapper/controller/PostRestController.java
rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/controller/PostRestController.java
diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/dto/PostDto.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/PostDto.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/modelmapper/dto/PostDto.java
rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/PostDto.java
diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/dto/UserDto.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/UserDto.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/modelmapper/dto/UserDto.java
rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/UserDto.java
diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/model/Post.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Post.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/modelmapper/model/Post.java
rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Post.java
diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/model/Preference.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Preference.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/modelmapper/model/Preference.java
rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Preference.java
diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/model/User.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/User.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/modelmapper/model/User.java
rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/User.java
diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/repository/PostRepository.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/repository/PostRepository.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/modelmapper/repository/PostRepository.java
rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/repository/PostRepository.java
diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/service/IPostService.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IPostService.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/modelmapper/service/IPostService.java
rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IPostService.java
diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/service/IUserService.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IUserService.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/modelmapper/service/IUserService.java
rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IUserService.java
diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/service/PostService.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/PostService.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/modelmapper/service/PostService.java
rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/PostService.java
diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/service/UserService.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/UserService.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/modelmapper/service/UserService.java
rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/UserService.java
diff --git a/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java b/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java
index 5179c66978..2e967751ad 100644
--- a/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java
+++ b/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java
@@ -24,8 +24,8 @@ import com.google.common.base.Preconditions;
@Configuration
@EnableTransactionManagement
@PropertySource({ "classpath:persistence-${envTarget:h2}.properties" })
-@ComponentScan({ "com.baeldung.persistence" })
-@EnableJpaRepositories(basePackages = "com.baeldung.persistence.dao")
+@ComponentScan(basePackages = { "com.baeldung.persistence", "com.baeldung.modelmapper" })
+@EnableJpaRepositories(basePackages = {"com.baeldung.persistence.dao", "com.baeldung.modelmapper.repository"})
public class PersistenceConfig {
@Autowired
@@ -39,7 +39,7 @@ public class PersistenceConfig {
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
- em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });
+ em.setPackagesToScan(new String[] { "com.baeldung.persistence.model", "com.baeldung.modelmapper.model" });
final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
// vendorAdapter.set
diff --git a/spring-boot-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java b/spring-boot-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java
index 25fbc4cc02..3db1ecb462 100644
--- a/spring-boot-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java
+++ b/spring-boot-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java
@@ -6,7 +6,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
-@SpringBootTest
+@SpringBootTest(classes = {SpringBootRestApplication.class})
public class SpringContextIntegrationTest {
@Test
diff --git a/spring-boot/src/test/java/com/baeldung/modelmapper/PostDtoUnitTest.java b/spring-boot-rest/src/test/java/com/baeldung/modelmapper/PostDtoUnitTest.java
similarity index 100%
rename from spring-boot/src/test/java/com/baeldung/modelmapper/PostDtoUnitTest.java
rename to spring-boot-rest/src/test/java/com/baeldung/modelmapper/PostDtoUnitTest.java
diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml
index ed2d8259df..401e0289e8 100644
--- a/spring-boot/pom.xml
+++ b/spring-boot/pom.xml
@@ -153,12 +153,6 @@
javax.validation
validation-api
-
-
- org.modelmapper
- modelmapper
- ${modelmapper.version}
-
@@ -256,7 +250,6 @@
5.2.4
18.0
2.2.4
- 2.3.2
diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/PostApplication.java b/spring-boot/src/main/java/com/baeldung/modelmapper/PostApplication.java
deleted file mode 100644
index 7684c43648..0000000000
--- a/spring-boot/src/main/java/com/baeldung/modelmapper/PostApplication.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.baeldung.modelmapper;
-
-import org.modelmapper.ModelMapper;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Bean;
-
-@SpringBootApplication
-public class PostApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(PostApplication.class, args);
- }
-
- @Bean
- public ModelMapper modelMapper() {
- return new ModelMapper();
- }
-
-}