diff --git a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java index 4bc4739ccd..078d7e6f88 100644 --- a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java +++ b/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java @@ -7,6 +7,7 @@ import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; @@ -17,7 +18,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; import com.google.common.base.Preconditions; -// @Configuration +@Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" }) diff --git a/spring-all/src/main/java/org/baeldung/web/IBeanB.java b/spring-all/src/main/java/org/baeldung/web/IServiceB.java similarity index 55% rename from spring-all/src/main/java/org/baeldung/web/IBeanB.java rename to spring-all/src/main/java/org/baeldung/web/IServiceB.java index 63357980ad..faf048cde5 100644 --- a/spring-all/src/main/java/org/baeldung/web/IBeanB.java +++ b/spring-all/src/main/java/org/baeldung/web/IServiceB.java @@ -1,5 +1,5 @@ package org.baeldung.web; -public interface IBeanB { +public interface IServiceB { // } diff --git a/spring-all/src/main/java/org/baeldung/web/ServiceA.java b/spring-all/src/main/java/org/baeldung/web/ServiceA.java index 47afde94c8..deee4c6e55 100644 --- a/spring-all/src/main/java/org/baeldung/web/ServiceA.java +++ b/spring-all/src/main/java/org/baeldung/web/ServiceA.java @@ -6,12 +6,10 @@ import org.springframework.transaction.annotation.Transactional; @Service @Transactional -public class ServiceA implements IServiceA { +public class ServiceA { @Autowired - private ServiceB serviceB; - - public ServiceA() { + public ServiceA(final IServiceB serviceB) { super(); } diff --git a/spring-all/src/main/java/org/baeldung/web/ServiceB.java b/spring-all/src/main/java/org/baeldung/web/ServiceB.java index 65b4215cc4..48ff0f2648 100644 --- a/spring-all/src/main/java/org/baeldung/web/ServiceB.java +++ b/spring-all/src/main/java/org/baeldung/web/ServiceB.java @@ -1,15 +1,11 @@ package org.baeldung.web; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional -public class ServiceB { - - @Autowired - private IServiceA serviceA; +public class ServiceB implements IServiceB { public ServiceB() { super(); diff --git a/spring-all/src/main/java/org/baeldung/web/Setup.java b/spring-all/src/main/java/org/baeldung/web/Setup.java index 653609e006..f04135d807 100644 --- a/spring-all/src/main/java/org/baeldung/web/Setup.java +++ b/spring-all/src/main/java/org/baeldung/web/Setup.java @@ -3,18 +3,17 @@ package org.baeldung.web; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.stereotype.Component; -@Component +// @Component public class Setup implements ApplicationListener { private boolean setupDone; @Autowired - IServiceA serviceA; + ServiceA serviceA; @Autowired - ServiceB serviceB; + IServiceB serviceB; public Setup() { super(); @@ -25,7 +24,8 @@ public class Setup implements ApplicationListener { @Override public final void onApplicationEvent(final ContextRefreshedEvent event) { if (!setupDone) { - // + System.out.println(); + setupDone = true; } }