У меня проблема с Spring RMI. Я хочу использовать RMI для подключения моей трехуровневой системы.У меня есть пакеты DOA на первом уровне, на втором уровне есть службы и контроллер для использования веб-службы. Я хочу подключить первый уровень ко второму с помощью RMI, и у меня возникли проблемы с автоматическим подключением сервера к моему клиенту RMI.
@SpringBootApplication
@ComponentScan("sep.via.dk.sep3JPA")
public class Sep3JpaApplication {
@Bean
public RemoteServer createBarServiceLink() {
RmiProxyFactoryBean rmiProxyFactoryBean= new RmiProxyFactoryBean();
rmiProxyFactoryBean.setServiceUrl("rmi://localhost:1099/helloworldrmi");
rmiProxyFactoryBean.setServiceInterface(RemoteServer.class);
rmiProxyFactoryBean.afterPropertiesSet();
System.out.println("client is running");
return (RemoteServer) rmiProxyFactoryBean.getObject();
}
public static void main(String[] args) throws AccessException, RemoteException, NotBoundException {
RemoteServer helloWorldRMI= SpringApplication.run(Sep3JpaApplication.class, args).getBean(RemoteServer.class);
RmiClient client = new RmiClient(helloWorldRMI);
System.out.println("================Client Side ========================");
System.out.println(helloWorldRMI.sayHelloRmi("FADI"));
}
Конфигурация
@Configuration
public class Config {
@Bean
RemoteExporter registerRMIExporter() {
RmiServiceExporter exporter = new RmiServiceExporter();
exporter.setServiceName("helloworldrmi");
exporter.setServiceInterface(RemoteServer.class);
exporter.setService(new RmiServer());
System.out.println("server is running");
return exporter;
}
Клиент
public class RmiClient {
private RemoteServer server;
public RmiClient(RemoteServer server) throws AccessException, RemoteException, NotBoundException {
this.server=server;
}
public void addCustomer(Customer customer) throws RemoteException {
server.getCustomerDAO().addCustomer(customer);
}
Сервис
@Service
public class CustomerServiceImplementation implements CustomerService {
@Autowired
public RmiClient rmiClient;
@Autowired
public MyPayment myPayment;
@Override
public boolean addCustomer(Customer customer) throws RemoteException {
boolean checkPayment = checkPayment();
if(checkPayment!=true) {
return false;
}
**************************
APPLICATION FAILED TO START
***************************
Description:
Field rmiClient in sep.via.dk.sep3JPA.service.customerService.CustomerServiceImplementation required a bean of type 'sep.via.dk.sep3JPA.rmiClient.RmiClient' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'sep.via.dk.sep3JPA.rmiClient.RmiClient' in your configuration.
пожалуйста, любая помощь может быть отличной