In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about the analysis of the use of duboo. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
I. background
With the development of the Internet and the continuous expansion of the scale of website applications, the conventional vertical application architecture has been unable to cope with, distributed service architecture and mobile computing architecture are imperative.
As more and more interfaces and implementation classes increase, there will be more and more xml configuration for duboo. In order to prevent hundreds of thousands of lines of code, reduce the workload of developers configuring xml, use duboo's annotation mode, and reduce the possibility of configuration problems!
II. Dubbo use cases
Duboo comments
API project: DubboServiceInterface
It's just an interface project! The interface is a normal interface!
Note: package the interface project into jar and put it into the server project and the client project respectively!
Server project: DubboServiceProvider
Implementation class fooserviceImpl.java
Package com.alibaba.dubbo.demo.imp
Import com.alibaba.dubbo.config.annotation.Service
Import com.alibaba.dubbo.demo.DemoService
@ Service (version= "1.0")
Public class FooServiceImpl implements DemoService {
@ Override
Public String sayHello (String name) {
Return "Hello" + name
}
}
Web.xml configuration scan content
DubboServiceProvider
Spring org.springframework.web.servlet.DispatcherServlet
one
Spring
*
Org.springframework.web.context.ContextLoaderListener
ContextConfigLocation classpath*:applicationContext.xml
ApplicationContext.xml configuration
Test class Provider
Package com.alibaba.dubbo.test
Import java.io.IOException
Import org.junit.Before
Import org.junit.Test
Import org.springframework.context.support.ClassPathXmlApplicationContext
Public class Provider {
@ Before
Public void setUp () throws Exception {
}
@ Test
Public void testMain () throws IOException {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext (
New String [] {"applicationContext.xml"})
Context.start ()
System.in.read (); / / Press any key to exit
}
}
Jar package under lib
Client project: DubboServiceConsumer
Web.xml configuration scan content
ApplicationContext.xml file
Test class: Consumer
Package com.unj.dubbotest.action
Import java.io.IOException
Import org.junit.Test
Import org.springframework.context.support.ClassPathXmlApplicationContext
Import com.alibaba.dubbo.config.annotation.Reference
Import com.alibaba.dubbo.demo.DemoService
Public class Consumer {
@ Reference (version = "1.0")
Private DemoService demoService
@ Test
Public void mainTest () throws IOException {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext (
New String [] {"applicationContext.xml"})
Context.start ()
DemoService = (DemoService) context.getBean ("demoService"); / / get remote service agent
String hello = demoService.sayHello ("world"); / / execute remote methods
System.out.println (hello); / / display the result of the call
}
}
Jar package under lib
After reading the above, do you have any further understanding of the usage analysis of duboo? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.