Native microservice - recommended structure
Below is shown default microservice structure pattern with configured JLupinDelegator for binary communication and more complex structure prepared for development.
Implementation module structure:
+--+ com
|
+--+ example
|
+--+ configuration
| |
| +--- ExampleServletSpringConfiguration.java.java
|
+--- controller
|
+--- SpringBootApplicationStarter.java
ExampleServletSpringConfiguration.java
:
package com.example.configuration;
import com.jlupin.impl.client.util.JLupinClientUtil;
import com.jlupin.interfaces.client.delegator.JLupinDelegator;
import com.jlupin.interfaces.common.enums.PortType;
import com.jlupin.servlet.monitor.annotation.EnableJLupinSpringBootServletMonitor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan("com.example")
@EnableJLupinSpringBootServletMonitor
public class ExampleServletSpringConfiguration {
@Bean
public JLupinDelegator getJLupinDelegator() {
return JLupinClientUtil.generateInnerMicroserviceLoadBalancerDelegator(PortType.JLRMC);
}
// @Bean(name = "exampleService")
// public ExampleService getExampleService() {
// return JLupinClientUtil.generateRemote(getJLupinDelegator(), "example-microservice", ExampleService.class);
// }
}
SpringBootApplicationStarter.java
:
package com.example;
import com.example.configuration.ExampleServletSpringConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootApplicationStarter {
public static void main(String[] args) throws Exception {
SpringApplication.run(ExampleServletSpringConfiguration.class, args);
}
}