Created
July 31, 2021 15:41
-
-
Save yooniversal/96a885723dd1a9aca580b14c35d391fe to your computer and use it in GitHub Desktop.
데이터 스프링 JPA : SpringConfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hello.hellospring.service; | |
import hello.hellospring.repository.*; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import javax.persistence.EntityManager; | |
import javax.sql.DataSource; | |
@Configuration | |
public class SpringConfig { | |
private final MemberRepository memberRepository; | |
@Autowired | |
public SpringConfig(MemberRepository memberRepository) { | |
this.memberRepository = memberRepository; | |
} | |
@Bean | |
public MemberService memberService() { | |
return new MemberService(memberRepository); | |
} | |
//@Bean | |
//public MemberRepository memberRepository() { | |
//return new MemoryMemberRepository(); | |
//return new JdbcMemberRepository(dataSource); | |
//return new JdbcTemplateMemberRepository(dataSource); | |
//return new JpaMemberRepository(em); | |
//} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment