- Apache Maven <dependencies> <dependency> <groupId>org.amdatu.remote</groupId> <artifactId>org.amdatu.remote.base</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>org.amdatu.remote</groupId> <artifactId>org.amdatu.remote.discovery.configuration</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>org.amdatu.remote</groupId> <artifactId>org.amdatu.remote.topology.manager</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>org.amdatu.remote</groupId> <artifactId>org.amdatu.remote.discovery.zookeeper.client</artifactId> <version>1.0.0</version> </dependency> </dependencies> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.amdatu.remote.discovery.configuration" activate="activate" deactivate="deactivate" modified="modified" configuration-pid="org.amdatu.remote.discovery" immediate="true"> <implementation class="org.amdatu.remote.discovery.DiscoveryConfigurationImpl"/> <property name="protocol" value="http"/> <property name="port" value="8080"/> <property name="path" value="/my-app"/> </scr:component> public interface HelloService { String sayHello(String name); } @Service public class HelloServiceImpl implements HelloService { @Override public String sayHello(String name) { return "Hello, " + name + "!"; } } <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.example.helloworld"> <implementation class="org.example.HelloServiceImpl"/> <service> <provide interface="org.example.HelloService"/> </service> </scr:component> @Component public class HelloClient { @Reference private HelloService helloService; public void greet(String name) { String greeting = helloService.sayHello(name); System.out.println(greeting); } } mvn clean install java -jar target/my-app.jar


上一篇:
下一篇:
切换中文