java - 无法在我的测试类: modifier static not allowed here中创建Lombok类

标签 java lombok

我想在测试类中创建一个Lombok类

@RunWith(SpringRunner.class)
@SpringBootTest
public class HostelIntegrationTest  {


    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @JsonInclude(NON_NULL)
    @EqualsAndHashCode
    class User {
        String property1;
        Instant property2;
        Integer property3;
    }

但是我得到这个编译错误:

modifier static not allowed here

最佳答案

@Builder在内部创建static内部类。
问题可能是非静态内部类中的静态内部类。

尝试使User也成为static

//other annotations
@Builder    
static class User {
    String property1;
    Instant property2;
    Integer property3;
}

关于java - 无法在我的测试类: modifier static not allowed here中创建Lombok类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59785541/

相关文章:

java - 在Java中从一维数组快速转换为二维

java - 在本地模式下运行多个storm拓扑

java - 使用 lombok 构建器时覆盖默认值

java - Lombok getter/setter vs Java 14 记录

java - 在 maven 中创建并安装 de-lomboked 源 jar

java - 不存在像默认构造函数这样的创建者,无法从对象值反序列化(没有基于委托(delegate)或属性的创建者)

java - 使用@ConfigurationProperties进行嵌套或直接访问

java - 使用哈希码比较 Map 的关键元素

java - 如何将事件从我的 ActorRef 发送到所有使用 akka fsm 创建的子项?

java - onResponse返回变量或抛出异常Retrofit 2.0