6、Lombok-速查手册:常用注解语法与生成代码对照表

【投稿赢 iPhone 17】「我的第一个开源项目」故事征集:用代码换C位出道! 10w+人浏览 1.6k人参与

使用说明:本手册按功能分类整理 Lombok 常用注解,包含完整参数说明默认行为生成代码示例,便于开发时快速查阅。


1. 基础 POJO、DTO、VO 注解

@Getter / @Setter

注解位置
  • 类级别:作用于所有非静态字段
  • 字段级别:作用于单个字段
参数说明
参数类型默认值说明
valueAccessLevelPUBLIC生成方法的访问级别
onMethod_Annotation[]{}为生成的方法添加注解(Java 8+ 语法)
onParam_Annotation[]{}为 setter 参数添加注解

💡 AccessLevel 可选值PUBLICPROTECTEDPACKAGEPRIVATENONE

使用示例
// 类级别
@Getter
@Setter
public class User {
    private String name;
    private int age;
}

// 字段级别 + 自定义访问级别
public class SecureUser {
    @Getter(AccessLevel.PROTECTED)
    @Setter(AccessLevel.PRIVATE)
    private String password;
    
    @Getter
    @Setter
    private String username;
}
生成代码
// User 类生成
public String getName() { return this.name; }
public void setName(String name) { this.name = name; }
public int getAge() { return this.age; }
public void setAge(int age) { this.age = age; }

// SecureUser 类生成
protected String getPassword() { return this.password; }
private void setPassword(String password) { this.password = password; }
public String getUsername() { return this.username; }
public void setUsername(String username) { this.username = username; }

@ToString

参数说明
参数类型默认值说明
includeFieldNamesbooleantrue是否包含字段名
excludeString[]{}排除的字段名
ofString[]{}仅包含的字段(优先级高于 exclude)
callSuperbooleanfalse是否调用父类 toString()
doNotUseGettersbooleanfalse直接访问字段而非 getter
使用示例
@ToString(exclude = {"password", "secretKey"})
public class User {
    private String username;
    private String password;
    private String secretKey;
    private int loginCount;
}

@ToString(of = {"id", "name"}, callSuper = true)
public class Employee extends Person {
    private Long id;
    private String name;
    private Double salary; // 不会出现在 toString 中
}
生成代码
// User 类生成
@Override
public String toString() {
    return "User(username=" + this.username + 
           ", loginCount=" + this.loginCount + ")";
}

// Employee 类生成
@Override
public String toString() {
    return super.toString() + 
           "Employee(id=" + this.id + 
           ", name=" + this.name + ")";
}

@EqualsAndHashCode

参数说明
参数类型默认值说明
excludeString[]{}排除的字段
ofString[]{}仅包含的字段
callSuperbooleanfalse是否包含父类字段
doNotUseGettersbooleanfalse直接访问字段
cacheStrategyCacheStrategyCACHE_NOTHING缓存策略(高级用法)
使用示例
@EqualsAndHashCode(exclude = {"lastModified"})
public class Article {
    private Long id;
    private String title;
    private LocalDateTime lastModified;
}

@EqualsAndHashCode(callSuper = true)
public class Dog extends Animal {
    private String breed;
}
生成代码
// Article 类生成
@Override
public boolean equals(Object o) {
    if (o == this) return true;
    if (!(o instanceof Article)) return false;
    Article other = (Article) o;
    if (!other.canEqual(this)) return false;
    final Object this$id = this.id;
    final Object other$id = other.id;
    if (this$id == null ? other$id != null : !this$id.equals(other$id)) return false;
    final Object this$title = this.title;
    final Object other$title = other.title;
    if (this$title == null ? other$title != null : !this$title.equals(other$title)) return false;
    return true;
}

@Override
public int hashCode() {
    final int PRIME = 59;
    int result = 1;
    result = result * PRIME + (this.id == null ? 43 : this.id.hashCode());
    result = result * PRIME + (this.title == null ? 43 : this.title.hashCode());
    return result;
}

// canEqual 方法(用于继承场景)
protected boolean canEqual(Object other) {
    return other instanceof Article;
}

2. 组合注解

@Data

等价注解组合
@Getter
@Setter
@ToString
@EqualsAndHashCode
@RequiredArgsConstructor
注意事项
  • 不生成无参构造器!需要额外添加 @NoArgsConstructor
  • 所有字段都参与 equals/hashCode/toString
使用示例
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Product {
    private Long id;
    private String name;
    private Double price;
}
生成代码

包含上述所有注解的生成内容,外加:

// 无参构造器
public Product() {}

// 全参构造器
public Product(Long id, String name, Double price) {
    this.id = id;
    this.name = name;
    this.price = price;
}

@Value

特点
  • 创建不可变类
  • 所有字段自动变为 private final
  • 只生成 getter,不生成 setter
  • 生成全参构造器
使用示例
@Value
public class Point {
    int x;
    int y;
}
生成代码
public final class Point {
    private final int x;
    private final int y;
    
    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
    
    public int getX() { return this.x; }
    public int getY() { return this.y; }
    
    // toString, equals, hashCode 方法...
    
    // 注意:没有 setter 方法!
}

3. 构造器注解

@NoArgsConstructor

参数说明
参数类型默认值说明
accessAccessLevelPUBLIC构造器访问级别
forcebooleanfalse强制生成(即使有 final 字段)
使用示例
@NoArgsConstructor
public class User {
    private String name;
}

@NoArgsConstructor(force = true)
public class ImmutableUser {
    private final String id = "default";
    private final String name;
}
生成代码
// User 类
public User() {}

// ImmutableUser 类(force = true)
public ImmutableUser() {
    // final 字段被强制初始化为默认值
    this.name = null; // 注意:这可能导致 NullPointerException
}

@AllArgsConstructor

参数说明
参数类型默认值说明
accessAccessLevelPUBLIC构造器访问级别
staticNameString""生成静态工厂方法
使用示例
@AllArgsConstructor(staticName = "of")
public class Coordinate {
    private int x;
    private int y;
}
生成代码
// 常规构造器
public Coordinate(int x, int y) {
    this.x = x;
    this.y = y;
}

// 静态工厂方法(staticName = "of")
public static Coordinate of(int x, int y) {
    return new Coordinate(x, y);
}

@RequiredArgsConstructor

生成规则

为以下字段生成构造器:

  • 所有 final 字段
  • 所有标记 @NonNull 的字段
使用示例
@RequiredArgsConstructor
public class UserService {
    private final UserRepository userRepository;
    
    @NonNull
    private String defaultRole;
}
生成代码
public UserService(UserRepository userRepository, String defaultRole) {
    this.userRepository = userRepository;
    if (defaultRole == null) {
        throw new NullPointerException("defaultRole is marked non-null but is null");
    }
    this.defaultRole = defaultRole;
}

4. Builder 模式注解

@Builder

参数说明
参数类型默认值说明
builderMethodNameString"builder"Builder 方法名
buildMethodNameString"build"build 方法名
toBuilderbooleanfalse生成 toBuilder 方法
使用示例
@Builder(builderMethodName = "newBuilder", buildMethodName = "create")
public class Order {
    private String orderId;
    private Double amount;
}
生成代码
// Builder 内部类
public static class OrderBuilder {
    private String orderId;
    private Double amount;
    
    OrderBuilder() {}
    
    public OrderBuilder orderId(String orderId) {
        this.orderId = orderId;
        return this;
    }
    
    public OrderBuilder amount(Double amount) {
        this.amount = amount;
        return this;
    }
    
    public Order create() { // buildMethodName = "create"
        return new Order(orderId, amount);
    }
}

// Builder 方法
public static OrderBuilder newBuilder() { // builderMethodName = "newBuilder"
    return new OrderBuilder();
}

@Singular(集合字段支持)

支持的集合类型
  • List<T>element(T)elements(Collection<T>)
  • Set<T>element(T)elements(Collection<T>)
  • Map<K,V>entry(K, V)entries(Map<K,V>)
使用示例
@Builder
public class ShoppingCart {
    @Singular("product")
    private List<String> products;
    
    @Singular
    private Map<String, Integer> quantities;
}
使用方式
ShoppingCart cart = ShoppingCart.builder()
    .product("Laptop")           // 添加单个元素
    .product("Mouse")            // 继续添加
    .products(Arrays.asList("Keyboard", "Monitor")) // 批量添加
    .entry("Laptop", 1)          // Map 单个条目
    .entries(Map.of("Mouse", 2, "Keyboard", 1))     // Map 批量
    .build();

5. 日志注解

@Slf4j

生成代码
// 源码
@Slf4j
public class MyService {
    public void doSomething() {
        log.info("Doing something");
    }
}

// 生成
public class MyService {
    private static final org.slf4j.Logger log = 
        org.slf4j.LoggerFactory.getLogger(MyService.class);
    
    public void doSomething() {
        log.info("Doing something");
    }
}
其他日志框架支持
注解生成的日志实例类型
@Logjava.util.logging.Logger
@Log4jorg.apache.log4j.Logger
@Log4j2org.apache.logging.log4j.Logger
@CommonsLogorg.apache.commons.logging.Log
@JBossLogorg.jboss.logging.Logger

6. 高级功能注解

@SneakyThrows

参数说明
参数类型默认值说明
valueClass<? extends Throwable>[]Exception.class要 sneaky 抛出的异常类型
使用示例
@SneakyThrows
public String readFile(String path) {
    return Files.readString(Paths.get(path)); // IOException
}

@SneakyThrows({IOException.class, SQLException.class})
public void doDatabaseOperation() {
    // 可能抛出两种检查异常
}
生成代码
public String readFile(String path) {
    try {
        return Files.readString(Paths.get(path));
    } catch (IOException e) {
        throw lombok.Lombok.sneakyThrow(e);
    }
}

@Cleanup

参数说明
参数类型默认值说明
valueString"close"清理方法名
使用示例
public byte[] readFile(String path) throws IOException {
    @Cleanup
    FileInputStream fis = new FileInputStream(path);
    return fis.readAllBytes();
}

public void customResource() {
    @Cleanup("destroy")
    MyResource resource = new MyResource();
    // 使用 resource
} // 自动调用 resource.destroy()
生成代码
public byte[] readFile(String path) throws IOException {
    FileInputStream fis = new FileInputStream(path);
    try {
        return fis.readAllBytes();
    } finally {
        if (fis != null) {
            fis.close();
        }
    }
}

@With

使用示例
@With
public class Point {
    private final int x;
    private final int y;
}
生成代码
public Point withX(int x) {
    return this.x == x ? this : new Point(x, this.y);
}

public Point withY(int y) {
    return this.y == y ? this : new Point(this.x, y);
}

7. 快速参考表

注解主要用途关键参数注意事项
@Getter/@Setter生成访问器value(AccessLevel)可控制访问级别
@ToString生成 toStringexclude, of, callSuper敏感字段务必排除
@EqualsAndHashCode生成相等性方法exclude, of, callSuper继承时设 callSuper=true
@DataPOJO 万能注解不生成无参构造器
@Value不可变对象字段自动 final
@NoArgsConstructor无参构造器forceJPA/JSON 必需
@AllArgsConstructor全参构造器staticName可生成静态工厂
@RequiredArgsConstructor必需字段构造器Spring 构造器注入推荐
@BuilderBuilder 模式builderMethodName, toBuilder复杂对象创建首选
@Singular集合 Builder 支持配合 @Builder 使用
@Slf4j日志实例推荐 SLF4J
@SneakyThrows绕过检查异常value谨慎使用
@Cleanup自动资源管理value(方法名)替代 try-with-resources
@With不可变副本函数式编程友好

8. 使用建议

✅ 推荐组合

// DTO 标准写法
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(exclude = "password")
public class UserDTO {
    // ...
}

// 不可变配置类
@Value
@Builder
public class DatabaseConfig {
    // ...
}

❌ 避免组合

// 危险:JPA 实体不要用 @Data
@Data
@Entity
public class User { /* ... */ }

// 冗余:@Data 已包含 @Getter/@Setter
@Data
@Getter
@Setter
public class Product { /* ... */ }

💡 记住:Lombok 是工具,理解生成的代码才能用好它!

D:\develop\jdk17\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:59298,suspend=y,server=n -javaagent:C:\Users\czn\AppData\Local\JetBrains\IdeaIC2024.1\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "D:\dm\open-planogram\target\classes;C:\Users\czn\.m2\repository\org\springframework\boot\spring-boot-starter-security\3.5.5\spring-boot-starter-security-3.5.5.jar;C:\Users\czn\.m2\repository\org\springframework\boot\spring-boot-starter\3.5.5\spring-boot-starter-3.5.5.jar;C:\Users\czn\.m2\repository\org\springframework\boot\spring-boot\3.5.5\spring-boot-3.5.5.jar;C:\Users\czn\.m2\repository\org\springframework\boot\spring-boot-starter-logging\3.5.5\spring-boot-starter-logging-3.5.5.jar;C:\Users\czn\.m2\repository\ch\qos\logback\logback-classic\1.5.18\logback-classic-1.5.18.jar;C:\Users\czn\.m2\repository\ch\qos\logback\logback-core\1.5.18\logback-core-1.5.18.jar;C:\Users\czn\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.24.3\log4j-to-slf4j-2.24.3.jar;C:\Users\czn\.m2\repository\org\apache\logging\log4j\log4j-api\2.24.3\log4j-api-2.24.3.jar;C:\Users\czn\.m2\repository\org\slf4j\jul-to-slf4j\2.0.17\jul-to-slf4j-2.0.17.jar;C:\Users\czn\.m2\repository\jakarta\annotation\jakarta.annotation-api\2.1.1\jakarta.annotation-api-2.1.1.jar;C:\Users\czn\.m2\repository\org\yaml\snakeyaml\2.4\snakeyaml-2.4.jar;C:\Users\czn\.m2\repository\org\springframework\spring-aop\6.2.10\spring-aop-6.2.10.jar;C:\Users\czn\.m2\repository\org\springframework\spring-beans\6.2.10\spring-beans-6.2.10.jar;C:\Users\czn\.m2\repository\org\springframework\security\spring-security-config\6.5.3\spring-security-config-6.5.3.jar;C:\Users\czn\.m2\repository\org\springframework\spring-context\6.2.10\spring-context-6.2.10.jar;C:\Users\czn\.m2\repository\org\springframework\security\spring-security-web\6.5.3\spring-security-web-6.5.3.jar;C:\Users\czn\.m2\repository\org\springframework\spring-expression\6.2.10\spring-expression-6.2.10.jar;C:\Users\czn\.m2\repository\org\springframework\boot\spring-boot-starter-web\3.5.5\spring-boot-starter-web-3.5.5.jar;C:\Users\czn\.m2\repository\org\springframework\boot\spring-boot-starter-json\3.5.5\spring-boot-starter-json-3.5.5.jar;C:\Users\czn\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.19.2\jackson-datatype-jdk8-2.19.2.jar;C:\Users\czn\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.19.2\jackson-datatype-jsr310-2.19.2.jar;C:\Users\czn\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.19.2\jackson-module-parameter-names-2.19.2.jar;C:\Users\czn\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\3.5.5\spring-boot-starter-tomcat-3.5.5.jar;C:\Users\czn\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\10.1.44\tomcat-embed-core-10.1.44.jar;C:\Users\czn\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\10.1.44\tomcat-embed-el-10.1.44.jar;C:\Users\czn\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\10.1.44\tomcat-embed-websocket-10.1.44.jar;C:\Users\czn\.m2\repository\org\springframework\spring-web\6.2.10\spring-web-6.2.10.jar;C:\Users\czn\.m2\repository\io\micrometer\micrometer-observation\1.15.3\micrometer-observation-1.15.3.jar;C:\Users\czn\.m2\repository\io\micrometer\micrometer-commons\1.15.3\micrometer-commons-1.15.3.jar;C:\Users\czn\.m2\repository\org\springframework\spring-webmvc\6.2.10\spring-webmvc-6.2.10.jar;C:\Users\czn\.m2\repository\com\baomidou\mybatis-plus-boot-starter\3.5.4.1\mybatis-plus-boot-starter-3.5.4.1.jar;C:\Users\czn\.m2\repository\com\baomidou\mybatis-plus\3.5.4.1\mybatis-plus-3.5.4.1.jar;C:\Users\czn\.m2\repository\com\baomidou\mybatis-plus-core\3.5.4.1\mybatis-plus-core-3.5.4.1.jar;C:\Users\czn\.m2\repository\com\baomidou\mybatis-plus-annotation\3.5.4.1\mybatis-plus-annotation-3.5.4.1.jar;C:\Users\czn\.m2\repository\com\baomidou\mybatis-plus-extension\3.5.4.1\mybatis-plus-extension-3.5.4.1.jar;C:\Users\czn\.m2\repository\org\mybatis\mybatis\3.5.13\mybatis-3.5.13.jar;C:\Users\czn\.m2\repository\com\github\jsqlparser\jsqlparser\4.6\jsqlparser-4.6.jar;C:\Users\czn\.m2\repository\org\mybatis\mybatis-spring\2.1.1\mybatis-spring-2.1.1.jar;C:\Users\czn\.m2\repository\com\baomidou\mybatis-plus-spring-boot-autoconfigure\3.5.4.1\mybatis-plus-spring-boot-autoconfigure-3.5.4.1.jar;C:\Users\czn\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\3.5.5\spring-boot-autoconfigure-3.5.5.jar;C:\Users\czn\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\3.5.5\spring-boot-starter-jdbc-3.5.5.jar;C:\Users\czn\.m2\repository\com\zaxxer\HikariCP\6.3.2\HikariCP-6.3.2.jar;C:\Users\czn\.m2\repository\org\springframework\spring-jdbc\6.2.10\spring-jdbc-6.2.10.jar;C:\Users\czn\.m2\repository\org\springframework\spring-tx\6.2.10\spring-tx-6.2.10.jar;C:\Users\czn\.m2\repository\io\jsonwebtoken\jjwt-api\0.11.5\jjwt-api-0.11.5.jar;C:\Users\czn\.m2\repository\io\jsonwebtoken\jjwt-impl\0.11.5\jjwt-impl-0.11.5.jar;C:\Users\czn\.m2\repository\io\jsonwebtoken\jjwt-jackson\0.11.5\jjwt-jackson-0.11.5.jar;C:\Users\czn\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.19.2\jackson-databind-2.19.2.jar;C:\Users\czn\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.19.2\jackson-annotations-2.19.2.jar;C:\Users\czn\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.19.2\jackson-core-2.19.2.jar;C:\Users\czn\.m2\repository\com\mysql\mysql-connector-j\9.4.0\mysql-connector-j-9.4.0.jar;C:\Users\czn\.m2\repository\org\projectlombok\lombok\1.18.38\lombok-1.18.38.jar;C:\Users\czn\.m2\repository\org\slf4j\slf4j-api\2.0.17\slf4j-api-2.0.17.jar;C:\Users\czn\.m2\repository\org\springframework\spring-core\6.2.10\spring-core-6.2.10.jar;C:\Users\czn\.m2\repository\org\springframework\spring-jcl\6.2.10\spring-jcl-6.2.10.jar;C:\Users\czn\.m2\repository\org\springframework\security\spring-security-core\6.5.3\spring-security-core-6.5.3.jar;C:\Users\czn\.m2\repository\org\springframework\security\spring-security-crypto\6.5.3\spring-security-crypto-6.5.3.jar;D:\develop\idea\IntelliJ IDEA Community Edition 2024.1.2\lib\idea_rt.jar" com.wdk.rt.peacock.planogram.PlanogramOpenApplication Connected to the target VM, address: '127.0.0.1:59298', transport: 'socket' . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v3.5.5) 2025-09-10T14:22:39.640+08:00 INFO 22356 --- [planogram-open] [ main] c.w.r.p.p.PlanogramOpenApplication : Starting PlanogramOpenApplication using Java 17.0.2 with PID 22356 (D:\dm\open-planogram\target\classes started by czn in D:\dm\open-planogram) 2025-09-10T14:22:39.644+08:00 INFO 22356 --- [planogram-open] [ main] c.w.r.p.p.PlanogramOpenApplication : No active profile set, falling back to 1 default profile: "default" 2025-09-10T14:22:40.472+08:00 WARN 22356 --- [planogram-open] [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.example.demo20.mapper]' package. Please check your configuration. 2025-09-10T14:22:40.622+08:00 WARN 22356 --- [planogram-open] [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'userMapper' defined in file [D:\dm\open-planogram\target\classes\com\wdk\rt\peacock\planogram\mapper\UserMapper.class]: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String 2025-09-10T14:22:40.632+08:00 INFO 22356 --- [planogram-open] [ main] .s.b.a.l.ConditionEvaluationReportLogger : Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. 2025-09-10T14:22:40.651+08:00 ERROR 22356 --- [planogram-open] [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'userMapper' defined in file [D:\dm\open-planogram\target\classes\com\wdk\rt\peacock\planogram\mapper\UserMapper.class]: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:864) ~[spring-beans-6.2.10.jar:6.2.10] at org.springframework.beans.factory.support.AbstractBeanFactory.getType(AbstractBeanFactory.java:745) ~[spring-beans-6.2.10.jar:6.2.10] at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAnnotationOnBean(DefaultListableBeanFactory.java:817) ~[spring-beans-6.2.10.jar:6.2.10] at org.springframework.boot.sql.init.dependency.AnnotationDependsOnDatabaseInitializationDetector.detect(AnnotationDependsOnDatabaseInitializationDetector.java:36) ~[spring-boot-3.5.5.jar:3.5.5] at org.springframework.boot.sql.init.dependency.DatabaseInitializationDependencyConfigurer$DependsOnDatabaseInitializationPostProcessor.detectDependsOnInitializationBeanNames(DatabaseInitializationDependencyConfigurer.java:152) ~[spring-boot-3.5.5.jar:3.5.5] at org.springframework.boot.sql.init.dependency.DatabaseInitializationDependencyConfigurer$DependsOnDatabaseInitializationPostProcessor.postProcessBeanFactory(DatabaseInitializationDependencyConfigurer.java:115) ~[spring-boot-3.5.5.jar:3.5.5] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:363) ~[spring-context-6.2.10.jar:6.2.10] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:197) ~[spring-context-6.2.10.jar:6.2.10] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:791) ~[spring-context-6.2.10.jar:6.2.10] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:609) ~[spring-context-6.2.10.jar:6.2.10] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.5.5.jar:3.5.5] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-3.5.5.jar:3.5.5] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-3.5.5.jar:3.5.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) ~[spring-boot-3.5.5.jar:3.5.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361) ~[spring-boot-3.5.5.jar:3.5.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350) ~[spring-boot-3.5.5.jar:3.5.5] at com.wdk.rt.peacock.planogram.PlanogramOpenApplication.main(PlanogramOpenApplication.java:12) ~[classes/:na] Disconnected from the target VM, address: '127.0.0.1:59298', transport: 'socket' Process finished with exit code 1 这个是什么问题
09-11
package com.ghc.subject.vo; import cn.afterturn.easypoi.excel.annotation.Excel; import com.baomidou.mybatisplus.extension.activerecord.Model; import com.fasterxml.jackson.annotation.JsonFormat; import com.ghc.subject.domain.CtmsSubjectDrugHandleDetail; import com.ghc.utils.Annotation; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import java.util.Date; import java.util.List; /** * @author ghc * @date 2020-08-07 * 受试者药物发放回收详情 */ @Data @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class CtmsSubjectDrugSendRecoveryVo extends Model<CtmsSubjectDrugSendRecoveryVo> { /** * TODO 受试者药品发放回收记录详情id **/ private Long id; /** * TODO ctms_subject_pre_drug 处方药物记录id **/ private Long subjectPreDrugId; /** * 受试者id */ private Long subjectId; /** * 库存药品id */ private Long drugStockId; /** * TODO 该药物id发放数量 **/ @Excel(name = "发放数量", orderNum = "8", width = 30) private String drugAmountSpecsUnit; private String drugSendAmount; /** * 类型 * 1:发放 * 2:回收 * 3:配液 * 4:输液 * 5: 已核对 */ //@Excel(name = "类型 1:发放 2:回收 ") @Excel(name = "状态", orderNum = "11", width = 30, replace = {"已发放_1","已回收_2","配液_3","输液_4","已核对_5"}) private Integer type; /** * TODO 项目id **/ private Long projectId; /** * TODO 回收药物数量 **/ @Annotation("回收数量") @Excel(name = "回收药物数量", orderNum = "22", width = 30) private String recoveryDrugAmount; /** * TODO 回收包装数量 **/ @Annotation("回收空包装数量") @Excel(name = "回收空包装数量", orderNum = "23", width = 30) private String recoveryPackAmount; /** * 药品条码 */ @Excel(name = "药物条码",orderNum = "1",width = 30) private String barCode; /** * TODO 药物条码数据 **/ private String[] barCodes; /** * TODO 药物名称 **/ @Excel(name = "药物名称",orderNum = "2",width = 30) private String drugName; /** * TODO 药品编号 **/ @Excel(name = "药品编号",orderNum = "3",width = 30) private String drugNumber; /** * TODO 药品批号 **/ @Excel(name = "批号",orderNum = "4",width = 30) private String drugBatchNumber; /** * TODO 药品有效期 **/ @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8", shape = JsonFormat.Shape.STRING) @Excel(name = "有效期",orderNum = "5",width = 30,exportFormat = "yyyy-MM-dd") private Date validDate; /** * TODO 规格剂量 **/ private String specsDose; /** * TODO 规格单位 **/ private String specsUnit; /** * TODO 规格数量 **/ private String specsAmount; /** * TODO 包装数量 **/ private String packAmount; /** * TODO 包装单位 **/ private String packUnit; /** * TODO 发放数量后面拼接的单位,specs_unit拼接specsUnit,pack_unit拼接packUnit **/ private String usePackUnit; /** * TODO 随机号 **/ @Excel(name = "受试者随机号", orderNum = "10", width = 30) private String randomNumber; /** * TODO 发药人 **/ @Annotation("发放人") @Excel(name = "发放人", orderNum = "12", width = 30) private String dispensingPerson; /** * TODO 发药时间 **/ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING) private Date createDate; /** * TODO 领取人 **/ @Annotation("领取转运人") @Excel(name = "领取核对人", orderNum = "14", width = 30) private String receivePerson; /** * TODO 领取时间 **/ @Annotation("领取时间") @Excel(name = "领取时间", orderNum = "15", width = 30, exportFormat = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING) private Date receiveTime; /** * TODO 收药人 **/ @Annotation("发药人") @Excel(name = "发药人", orderNum = "20", width = 30) private String senddrugPerson; /** * TODO 收药日期 **/ @Annotation("发药时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING) @Excel(name = "发药时间", orderNum = "21", width = 30, exportFormat = "yyyy-MM-dd HH:mm:ss") private Date senddrugTime; /** * TODO 回收人 **/ @Annotation("回收人") @Excel(name = "回收人", orderNum = "24", width = 30) private String reRecycler; /** * TODO 回收时间 **/ @Annotation("回收日期") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING) @Excel(name = "回收日期", orderNum = "25", width = 30, exportFormat = "yyyy-MM-dd HH:mm:ss") private Date reCreateDate; /** * TODO 转运,转交人(回收) **/ @Excel(name = "核对人", orderNum = "26", width = 30) private String reTransportPerson; /** * TODO 转运,转交时间(回收) **/ @Annotation("核对日期") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING) @Excel(name = "核对日期", orderNum = "27", width = 30, exportFormat = "yyyy-MM-dd HH:mm:ss") private Date reTransportTime; /** * TODO 访视名称 **/ @Excel(name = "访视", orderNum = "9", width = 30) private String visitName; private List<CtmsSubjectDrugHandleDetail> ctmsSubjectDrugHandleDetails; /** * 回收备注 */ @Excel(name = "药物回收备注",orderNum = "25",width = 30) private String reComment; /** * 药物核对备注 */ private String checkComment; /** * 处理类型 * 1:发放 * 2:回收 * 5: 已核对 */ private Integer handleType; /** * 受试者药品回收记录Id */ private String drugRecoveryId; private String changeComment; /** * ctms_drug_handle 药品发放处理记录id */ private String drugHandleId; /** * 从冰箱取出时间 */ @Annotation("从冰箱取出时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING) @Excel(name = "从冰箱取出时间", orderNum = "13", width = 30, exportFormat = "yyyy-MM-dd HH:mm:ss") private Date takeoutTime; /** * 接收人 */ @Excel(name = "接收人", orderNum = "18", width = 30) private String acceptPerson; /** * 接收时间 */ @Annotation("接收时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING) @Excel(name = "接收时间", orderNum = "19", width = 30, exportFormat = "yyyy-MM-dd HH:mm:ss") private Date acceptTime; @Excel(name = "转运人", orderNum = "16", width = 30) private String transportPerson; @Annotation("转交时间") @Excel(name = "转交时间", orderNum = "17", width = 30, exportFormat = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING) private Date transportTime; /** * 规格 specsDose + specsUnit */ @Excel(name = "规格",orderNum = "6",width = 30) private String specsDoseUnit; /** * 包装规格 specsAmount + specsUnit + packUnit */ @Excel(name = "包装规格",orderNum = "7",width = 30) private String specsAmountPackUnit; } 分析报错原因cn.afterturn.easypoi.exception.excel.ExcelExportException: Excel导出错误
08-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

龙茶清欢

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值