You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
887 B
27 lines
887 B
package com.bsmlab.dfx.agent.config;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@Service
|
|
@RequiredArgsConstructor
|
|
public class UserService {
|
|
private final DynamicRoutingDataSource dynamicRoutingDataSource;
|
|
private UserMapper userMapper;
|
|
|
|
public void fetchUsersFromDefault() {
|
|
dynamicRoutingDataSource.setDataSource("default");
|
|
System.out.println("🔹 Default DB에서 데이터 조회");
|
|
System.out.println(userMapper.findAll());
|
|
}
|
|
|
|
@Transactional
|
|
public void fetchUsersFromNewDB() {
|
|
dynamicRoutingDataSource.setDataSource("newDB");
|
|
System.out.println("🔹 New DB에서 데이터 조회");
|
|
System.out.println(userMapper.findAll());
|
|
}
|
|
}
|