springboot怎么静态加载@configurationProperties

本篇内容跳转介绍了事务“springboot怎么tomcat静态加载访问写@configurationProperties”的有关知识war,在实际案例的操作过程中,springboot怎么访问html,springboot怎么连接数据库,不少人都会遇到这样怎么学的困境,接下来就让小编带领大家学习一下如何处理多个这些情况吧!希望大家仔细阅读访问,能够接口学有所成!

平时开发,基本不改变的常量静态我们访问搭建都放在前端了配置项里装配测,如properties或yml文件里,这个时候为了页面只在启动项目交互时候进行前端加载。如何静态做呢?

我们通过项目springboot的 @ConfigurationProperties 注解和写static静态化对应入门部署属性进行。

但搭建如果操作前端不当开启,会导致包加载注解的数据搭建为空多个跳转,springboot怎么写单元测试,至于为什么,看下开启加载面的对外案例交互。

1、错误案例

//错误自动1:get\set都是读取提供静态注解页面事务方法html对外
@对外Component
@ConfigurationProperties(prefix = "mobile")
public class MobileConfig
{
    public static Integer preview;

    public static Integer getPreview() {
        return preview;
    }

    public static void setPreview(Integer preview) {
        MobileConfig.单元接口加载preview = preview;
    }
}
//错误2:跟第一种差不多,springboot怎么部署到tomcat,springboot怎么读取配置,只是对外用了lombok注解数据库代替数据库了get\set方法提供,springboot怎么静态加载@configurationProperties,get\set也都是静态方法
@Data
@Component
@ConfigurationProperties(prefix = "mobile")交互springboot
public class MobileConfig
{
    public static Integer preview;
}

2、成功案例

@配置多个注解测试tomcat部署Component
@ConfigurationProperties(prefix = "mobile")
public class MobileConfig
{
    public static Integer preview;

    public static Integer getPreview() {
        return preview;
    }

    public void setPreview(Integer preview) {
        MobileConfig.写读@configurationProperties加载preview = preview;
    }
}
@多个postman连接Data
@Component
@ConfigurationProperties(prefix = "mobile")
public class MobileConfig
{
    public static Integer preview;

    public void setPreview(Integer preview) {
        MobileConfig.项目接口包preview = preview;
    }
}

3、原因

spring在注入的时候配置,需要调用set 方法,如果这个方法是静态测postman方法,就没法html动态注入了,所以只需单元要把postman页面get方法加入static作为静态方法即可,如果用了单元@Data,只需要重写访问@configurationPropertiesset方法即可。

“springboot怎么读取静态读加载@configurationProperties”的内容就介绍到测这里了,感谢大家@configurationProperties的阅读。如果想了解更多行业相关的知识包可以事务关注蜗牛博客网测试连接站,springboot怎么和前端交互的,springboot怎么对外提供接口,小编将为大家输出更多高质量的实用文章!

免责声明:本站发布的内容(图片、视频和文字)以原创、转载springboot和分享为主,文章观点自动不接口war代表本网站立场,如果涉及侵权请联系站长邮箱:niceseo99@gmail.com进行自动举报,并提供相关证据,一经查实,将立刻读取删除涉嫌侵权内容。

评论

有免费节点资源,我们会通知你!加入纸飞机订阅群

×
天气预报查看日历分享网页手机扫码留言评论电报频道链接