栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Spring-Rest验证器

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Spring-Rest验证器

因此,似乎“保存”之前/之后的事件仅在PUT和PATCH上触发。发布时,将触发“创建”之前/之后的事件。

我再次使用

configurevalidatingRepositoryEventListener
覆盖以手动方式尝试了它,并且它起作用了。我不确定我在工作中与在家里所做的不同。我明天要看。

我肯定想听听其他人是否对它为什么行不通提出建议。

作为记录,这是新的Application.java类的外观。

package hello;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.context.annotation.Configuration;import org.springframework.context.annotation.import;import org.springframework.data.jpa.repository.config.EnableJpaRepositories;import org.springframework.data.rest.core.event.ValidatingRepositoryEventListener;import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;@Configuration@EnableJpaRepositories@import(RepositoryRestMvcConfiguration.class)@EnableAutoConfigurationpublic class Application extends RepositoryRestMvcConfiguration {    public static void main(String[] args) {        SpringApplication.run(Application.class, args);    }    @Override    protected void configurevalidatingRepositoryEventListener(ValidatingRepositoryEventListener validatingListener) {        validatingListener.addValidator("beforeCreate", new Peoplevalidator());    }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/514779.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号