Merge pull request #6720 from amit2103/BAEL-14089

[BAEL-14089] - Moved code for Entity to DTO article
This commit is contained in:
Loredana Crusoveanu 2019-04-16 00:02:40 +03:00 committed by GitHub
commit b1af7f30bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 17 additions and 31 deletions

View File

@ -63,6 +63,11 @@
<artifactId>htmlunit</artifactId> <artifactId>htmlunit</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>${modelmapper.version}</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -78,5 +83,6 @@
<start-class>com.baeldung.SpringBootRestApplication</start-class> <start-class>com.baeldung.SpringBootRestApplication</start-class>
<guava.version>27.0.1-jre</guava.version> <guava.version>27.0.1-jre</guava.version>
<xstream.version>1.4.11.1</xstream.version> <xstream.version>1.4.11.1</xstream.version>
<modelmapper.version>2.3.3</modelmapper.version>
</properties> </properties>
</project> </project>

View File

@ -1,7 +1,9 @@
package com.baeldung; package com.baeldung;
import org.modelmapper.ModelMapper;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication @SpringBootApplication
public class SpringBootRestApplication { public class SpringBootRestApplication {
@ -9,5 +11,10 @@ public class SpringBootRestApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(SpringBootRestApplication.class, args); SpringApplication.run(SpringBootRestApplication.class, args);
} }
@Bean
public ModelMapper modelMapper() {
return new ModelMapper();
}
} }

View File

@ -24,8 +24,8 @@ import com.google.common.base.Preconditions;
@Configuration @Configuration
@EnableTransactionManagement @EnableTransactionManagement
@PropertySource({ "classpath:persistence-${envTarget:h2}.properties" }) @PropertySource({ "classpath:persistence-${envTarget:h2}.properties" })
@ComponentScan({ "com.baeldung.persistence" }) @ComponentScan(basePackages = { "com.baeldung.persistence", "com.baeldung.modelmapper" })
@EnableJpaRepositories(basePackages = "com.baeldung.persistence.dao") @EnableJpaRepositories(basePackages = {"com.baeldung.persistence.dao", "com.baeldung.modelmapper.repository"})
public class PersistenceConfig { public class PersistenceConfig {
@Autowired @Autowired
@ -39,7 +39,7 @@ public class PersistenceConfig {
public LocalContainerEntityManagerFactoryBean entityManagerFactory() { public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource()); 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(); final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
// vendorAdapter.set // vendorAdapter.set

View File

@ -6,7 +6,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest @SpringBootTest(classes = {SpringBootRestApplication.class})
public class SpringContextIntegrationTest { public class SpringContextIntegrationTest {
@Test @Test

View File

@ -153,12 +153,6 @@
<groupId>javax.validation</groupId> <groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId> <artifactId>validation-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>${modelmapper.version}</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -256,7 +250,6 @@
<graphql-java-tools.version>5.2.4</graphql-java-tools.version> <graphql-java-tools.version>5.2.4</graphql-java-tools.version>
<guava.version>18.0</guava.version> <guava.version>18.0</guava.version>
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version> <git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
<modelmapper.version>2.3.2</modelmapper.version>
</properties> </properties>
</project> </project>

View File

@ -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();
}
}