Springboot集成Dubbo(以注解形式)

本文涉及的产品
注册配置 MSE Nacos/ZooKeeper,118元/月
服务治理 MSE Sentinel/OpenSergo,Agent数量 不受限
云原生网关 MSE Higress,422元/月
简介: Springboot集成Dubbo(以注解形式)

Springboot 集成 Dubbo(以注解形式)

网址


Dubbo 官方文档:http://dubbo.apache.org/zh-cn/docs/user/quick-start.html

Zookeeper 安装

单机安装,见官网


案例一

使用专用接口定义


项目总体结构如下

springboot-dubbo
----dubbo-api
  ----pom
  ----src
  ----main
            ----java
                ----top.simba1949.service.DubboService.java
----dubbo-provider
  ----pom
  ----src
  ----main
    ----java
    ----top.simba1949
      ----Application.java
      ----service.impl.DubboServiceImpl.java
  ----resources
    ----application.yml
----dubbo-consumer
  ----pom
  ----src
  ----main
    ----java
    ----top.simba1949
      ----Application.java
      ----controller.DubboController
  ----resources
    ----application.yml


父项目


用于管理项目依赖和版本控制

Springboot 集成 Dubbo 的依赖

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>dubbo</artifactId>
    <version>${dubbo.version}</version>
</dependency>
<dependency>
    <groupId>com.alibaba.boot</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>${dubbo-spring-boot-starter.version}</version>
</dependency>
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
</dependency>


pom.xml

<properties>
    <lombok.version>1.18.4</lombok.version>
    <dubbo.version>2.6.4 </dubbo.version>
    <dubbo-spring-boot-starter.version>0.2.0</dubbo-spring-boot-starter.version>
</properties>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.spring.platform</groupId>
            <artifactId>platform-bom</artifactId>
            <version>Cairo-SR6</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional> <!-- 表示依赖不会传递 -->
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>dubbo</artifactId>
        <version>${dubbo.version}</version>
    </dependency>
    <dependency>
        <groupId>com.alibaba.boot</groupId>
        <artifactId>dubbo-spring-boot-starter</artifactId>
        <version>${dubbo-spring-boot-starter.version}</version>
    </dependency>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-all</artifactId>
    </dependency>
</dependencies>
<build>
    <plugins>
        <!--编译插件-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <!-- 配置使用的 jdk 版本 -->
                <target>1.8</target>
                <source>1.8</source>
            </configuration>
        </plugin>
        <!--springboot-maven打包插件-->
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <!--资源拷贝插件-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <configuration>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <!--实现热部署插件-->
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
            </configuration>
        </plugin>
    </plugins>
    <!--IDEA是不会编译src的java目录的xml文件,如果需要读取,则需要手动指定哪些配置文件需要读取-->
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*</include>
            </includes>
        </resource>
    </resources>
</build>


接口定义 module

DubboService.java

package top.simba1949.service;
/**
 * @author SIMBA1949
 * @date 2019/1/21 22:34
 */
public interface DubboService {
    /**
     * HELLO
     * @param hello
     * @return
     */
    String str(String hello);
}


服务提供者 module

服务提供者依赖接口定义 module


pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>dubbo-01</artifactId>
        <groupId>top.simba1949</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>dubbo-01-producer</artifactId>
    <dependencies>
        <dependency>
            <groupId>top.simba1949</groupId>
            <artifactId>dubbo-01-service</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>


application.yml 配置文件

server:
  port: 8091
# dubbo 配置
dubbo:
  application:
    id: dubbo-producer
    name: dubbo-producer
  # dubbo 注册中心地址
  registry:
    address: zookeeper://192.168.239.147:2181
  # 服务提供者的协议名和端口
  protocol:
    server: true
    name: dubbo
    port: 20800


实现类 DubboServiceImpl.java 实现具体的业务逻辑

package top.simba1949.service.impl;
import com.alibaba.dubbo.config.annotation.Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import top.simba1949.service.DubboService;
/**
 * com.alibaba.dubbo.config.annotation.Service 是 Alibaba 包下的注解,表明这是 dubbo 服务提供者
 * @author SIMBA1949
 * @date 2019/1/21 22:34
 */
@Slf4j
@Component
@Service
public class DubboServiceImpl implements DubboService {
    @Override
    public String str(String hello) {
        log.info("服务提供者:" + hello);
        return "服务提供者道:" + hello;
    }
}


启动类 Application.java

package top.simba1949;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
 * @EnableDubbo 用于开启 dubbo 注解的扫描和自动配置
 * @author SIMBA1949
 * @date 2019/1/21 22:32
 */
@EnableDubbo
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

服务消费者 module

服务消费者依赖接口定义 module


pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>dubbo-01</artifactId>
        <groupId>top.simba1949</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>dubbo-01-consumer</artifactId>
    <dependencies>
        <dependency>
            <groupId>top.simba1949</groupId>
            <artifactId>dubbo-01-service</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>


application.yml

server:
  port: 8081
dubbo:
  application:
    id: dubbo-consumer
    name: dubbo-consumer
  registry:
    address: zookeeper://192.168.239.147:2181
  protocol:
    name: dubbo
    port: 20800
  consumer:
    check: false


调用服务的具体的类 DubboController.java

package top.simba1949.controller;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.simba1949.service.DubboService;
/**
 * @Reference 会自动注入 dubbo 服务
 * @author SIMBA1949
 * @date 2019/1/21 22:45
 */
@RestController
@RequestMapping
@Slf4j
public class DubboController {
    @Reference
    private DubboService dubboService;
    @GetMapping("hello")
    public String str(String hello){
        log.info("消费者消费前:" + hello);
        String str = dubboService.str(hello);
        log.info("消费者消费后:" + str);
        return str;
    }
}


启动类

package top.simba1949;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
 * @author SIMBA1949
 * @date 2019/1/21 22:43
 */
@SpringBootApplication
@EnableDubbo
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}


案例二

服务提供者和服务消费者,使用相同的接口和实体类,但是属于不同的文件


服务提供者

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>top.simba1949</groupId>
    <artifactId>dubbo-02-provider</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <lombok.version>1.18.4</lombok.version>
        <dubbo.version>2.6.4 </dubbo.version>
        <dubbo-spring-boot-starter.version>0.2.0</dubbo-spring-boot-starter.version>
        <fastjson.version>1.2.55</fastjson.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.spring.platform</groupId>
                <artifactId>platform-bom</artifactId>
                <version>Cairo-SR6</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional> <!-- 表示依赖不会传递 -->
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>${fastjson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <version>${dubbo.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba.boot</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>${dubbo-spring-boot-starter.version}</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <!--编译插件-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <!-- 配置使用的 jdk 版本 -->
                    <target>1.8</target>
                    <source>1.8</source>
                </configuration>
            </plugin>
            <!--springboot-maven打包插件-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!--资源拷贝插件-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <!--实现热部署插件-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
                </configuration>
            </plugin>
        </plugins>
        <!--IDEA是不会编译src的java目录的xml文件,如果需要读取,则需要手动指定哪些配置文件需要读取-->
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>
    </build>
</project>


application.yml

server:
  port: 8071
# DUBBO CONFIGURE
dubbo:
  application:
    id: springboot-dubbo-provider
    name: springboot-dubbo-provider
  registry:
    address: zookeeper://192.168.239.147:2181
  protocol:
    server: true
    name: dubbo
    port: 20801


实体类

package top.simba1949.common;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * @author SIMBA1949
 * @date 2019/1/21 23:45
 */
@Data
public class UserDto implements Serializable {
    private static final long serialVersionUID = 2223107801863147437L;
    private Long id;
    private String username;
    private Date birthday;
    private Boolean flag;
}


接口类

package top.simba1949.service;
import top.simba1949.common.UserDto;
/**
 * @author SIMBA1949
 * @date 2019/1/21 23:45
 */
public interface UserService {
    /**
     * USER
     * @param userStr
     * @return
     */
    UserDto user(String userStr);
}


接口实现类

package top.simba1949.service.impl;
import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import top.simba1949.common.UserDto;
import top.simba1949.service.UserService;
/**
 * @author SIMBA1949
 * @date 2019/1/21 23:45
 */
@Component
@Slf4j
@Service
public class UserServiceImpl implements UserService {
    @Override
    public UserDto user(String userStr) {
        log.info("服务提供者获取的数据为:" +  userStr);
        UserDto userDto = JSON.parseObject(userStr, UserDto.class);
        userDto.setUsername("服务提供者:" + userDto.getUsername());
        return userDto;
    }
}


启动类

server:
  port: 8071
# DUBBO CONFIGURE
dubbo:
  application:
    id: springboot-dubbo-provider
    name: springboot-dubbo-provider
  registry:
    address: zookeeper://192.168.239.147:2181
  protocol:
    server: true
    name: dubbo
    port: 20801


服务消费者

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>top.simba1949</groupId>
    <artifactId>dubbo-02-consumer</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <lombok.version>1.18.4</lombok.version>
        <dubbo.version>2.6.4 </dubbo.version>
        <dubbo-spring-boot-starter.version>0.2.0</dubbo-spring-boot-starter.version>
        <fastjson.version>1.2.55</fastjson.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.spring.platform</groupId>
                <artifactId>platform-bom</artifactId>
                <version>Cairo-SR6</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional> <!-- 表示依赖不会传递 -->
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>${fastjson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <version>${dubbo.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba.boot</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>${dubbo-spring-boot-starter.version}</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <!--编译插件-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <!-- 配置使用的 jdk 版本 -->
                    <target>1.8</target>
                    <source>1.8</source>
                </configuration>
            </plugin>
            <!--springboot-maven打包插件-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!--资源拷贝插件-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <!--实现热部署插件-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
                </configuration>
            </plugin>
        </plugins>
        <!--IDEA是不会编译src的java目录的xml文件,如果需要读取,则需要手动指定哪些配置文件需要读取-->
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>
    </build>
</project>


配置文件

server:
  port: 8079
# DUBBO CONFIGURE
dubbo:
  application:
    id: springboot-dubbo-consumer
    name: springboot-dubbo-consumer
  registry:
    address: zookeeper://192.168.239.147:2181
  protocol:
    name: dubbo
    port: 20801
  consumer:
    check: false


实体类

package top.simba1949.common;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * @author SIMBA1949
 * @date 2019/1/21 23:45
 */
@Data
public class UserDto implements Serializable {
    private static final long serialVersionUID = 2223107801863147437L;
    private Long id;
    private String username;
    private Date birthday;
    private Boolean flag;
}


接口类

package top.simba1949.service;
import top.simba1949.common.UserDto;
/**
 * @author SIMBA1949
 * @date 2019/1/21 23:45
 */
public interface UserService {
    /**
     * USER
     * @param userStr
     * @return
     */
    UserDto user(String userStr);
}


调用dubbo服务java类

package top.simba1949.controller;
import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.simba1949.common.UserDto;
import top.simba1949.service.UserService;
/**
 * @author SIMBA1949
 * @date 2019/1/21 23:58
 */
@RestController
@RequestMapping
@Slf4j
public class UserController {
    @Reference
    private UserService userService;
    @PostMapping("user")
    public UserDto user(@RequestBody UserDto userDto){
        log.info("消费者消费之前的数据:" +  userDto);
        String userStr = JSON.toJSONString(userDto);
        UserDto user = userService.user(userStr);
        log.info("消费者消费之后的数据:" + user);
        return user;
    }
}


启动类

package top.simba1949;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
 * @author SIMBA1949
 * @date 2019/1/21 23:43
 */
@EnableDubbo
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}


Dubbo Admin 管理的安装

Dubbo Admin 安装


相关实践学习
基于MSE实现微服务的全链路灰度
通过本场景的实验操作,您将了解并实现在线业务的微服务全链路灰度能力。
目录
相关文章
|
26天前
|
XML Java 数据格式
SpringBoot入门(8) - 开发中还有哪些常用注解
SpringBoot入门(8) - 开发中还有哪些常用注解
47 0
|
2月前
|
Java Spring
在使用Spring的`@Value`注解注入属性值时,有一些特殊字符需要注意
【10月更文挑战第9天】在使用Spring的`@Value`注解注入属性值时,需注意一些特殊字符的正确处理方法,包括空格、引号、反斜杠、新行、制表符、逗号、大括号、$、百分号及其他特殊字符。通过适当包裹或转义,确保这些字符能被正确解析和注入。
103 3
|
1月前
|
XML JSON Java
SpringBoot必须掌握的常用注解!
SpringBoot必须掌握的常用注解!
56 4
SpringBoot必须掌握的常用注解!
|
12天前
|
前端开发 Java Spring
探索Spring MVC:@Controller注解的全面解析
在Spring MVC框架中,`@Controller`注解是构建Web应用程序的基石之一。它不仅简化了控制器的定义,还提供了一种优雅的方式来处理HTTP请求。本文将全面解析`@Controller`注解,包括其定义、用法、以及在Spring MVC中的作用。
26 2
|
28天前
|
XML Java 数据库连接
SpringBoot集成Flowable:打造强大的工作流管理系统
在企业级应用开发中,工作流管理是一个核心组件,它能够帮助我们定义、执行和管理业务流程。Flowable是一个开源的工作流和业务流程管理(BPM)平台,它提供了强大的工作流引擎和建模工具。结合SpringBoot,我们可以快速构建一个高效、灵活的工作流管理系统。本文将探讨如何将Flowable集成到SpringBoot应用中,并展示其强大的功能。
93 1
|
1月前
|
Dubbo Java 应用服务中间件
深入探讨了“dubbo+nacos+springboot3的native打包成功后运行出现异常”的原因及解决方案
本文深入探讨了“dubbo+nacos+springboot3的native打包成功后运行出现异常”的原因及解决方案。通过检查GraalVM版本兼容性、配置反射列表、使用代理类、检查配置文件、禁用不支持的功能、查看日志文件、使用GraalVM诊断工具和调整GraalVM配置等步骤,帮助开发者快速定位并解决问题,确保服务的正常运行。
39 1
|
1月前
|
存储 缓存 Java
Spring缓存注解【@Cacheable、@CachePut、@CacheEvict、@Caching、@CacheConfig】使用及注意事项
Spring缓存注解【@Cacheable、@CachePut、@CacheEvict、@Caching、@CacheConfig】使用及注意事项
127 2
|
1月前
|
JSON Java 数据库
SpringBoot项目使用AOP及自定义注解保存操作日志
SpringBoot项目使用AOP及自定义注解保存操作日志
42 1
|
1月前
|
JSON Java API
springboot集成ElasticSearch使用completion实现补全功能
springboot集成ElasticSearch使用completion实现补全功能
38 1
|
2月前
|
架构师 Java 开发者
得物面试:Springboot自动装配机制是什么?如何控制一个bean 是否加载,使用什么注解?
在40岁老架构师尼恩的读者交流群中,近期多位读者成功获得了知名互联网企业的面试机会,如得物、阿里、滴滴等。然而,面对“Spring Boot自动装配机制”等核心面试题,部分读者因准备不足而未能顺利通过。为此,尼恩团队将系统化梳理和总结这一主题,帮助大家全面提升技术水平,让面试官“爱到不能自已”。
得物面试:Springboot自动装配机制是什么?如何控制一个bean 是否加载,使用什么注解?