<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 3.5 Spring Boot集成 支持SpringBoot2和SpringBoot3 ### 3.5.1 Spring Boot 3 ~~~xml <dependency> <groupId>com.ibeetl</groupId> <artifactId>beetl-springboot-starter-jdk17</artifactId> <version>3.16.2.RELEASE</version> </dependency> ~~~ Java代碼 ,使用@EnableBeetl ```java @SpringBootApplication @EnableBeetl public class TestSpringBootApplication { public static void main(String[] args) { SpringApplication.run(TestSpringBootApplication.class, args); } } ``` starter 自動處理以btl結尾的視圖,模板根目錄是Spring Boot默認的templates目錄。如下配置可以修改beetl部分屬性 * beetl-beetlsql.dev,默認為true,即自動檢查模板變化 * beetl.enabled 默認為true,集成beetl。 * beetl.suffix 默認為btl,表示只處理視圖后綴為btl的模板,比如controller里代碼是“return /common/index.btl”,則能被Beetl處理,你寫成"return /common/index",或者"/common/index.html",都會出現404錯誤。 Starter可以實現BeetlTemplateCustomize來定制Beetl ~~~java @Configuration public MyConfig{ @Bean public BeetlTemplateCustomize beetlTemplateCustomize(){ return new BeetlTemplateCustomize(){ public void customize(GroupTemplate groupTemplate){ } }; } } ~~~ ### 3.5.2 Spring Boot 2 ~~~xml <dependency> <groupId>com.ibeetl</groupId> <artifactId>beetl-spring-boot-starter-classic</artifactId> <version>3.14.1.RELEASE</version> </dependency> ~~~ Java代碼 ,使用@EnableBeetl ```java @SpringBootApplication @EnableBeetl public class TestSpringBootApplication { public static void main(String[] args) { SpringApplication.run(TestSpringBootApplication.class, args); } } ``` 關于Beetl配置同Spring Boot3 ### 3.5.3 兼容 Spring Boot 2 (不推薦) 在3.14版本之前,使用的是`beetl-framework-starter` ,也適用于Spring Boot 2 ~~~xml <dependency> <groupId>com.ibeetl</groupId> <artifactId>beetl-framework-starter</artifactId> <version>1.2.31.Beetl.RELEASE</version> </dependency> ~~~ 這種方式不需是Spring Starter方式,自動集成Beetl,不需要@EnableBeetl 注解 ### 3.5.4 自己集成 無論上面那種方式,本質上是構造BeetlGroupUtilConfiguration,和創建 BeetlSpringViewResolver實例,可以自己定義集成方式,參考代碼如下 ```java @Configuration public class BeetlConf { @Value("${beetl.templatesPath}") String templatesPath;//模板根目錄 ,比如 "templates" @Bean(name = "beetlConfig") public BeetlGroupUtilConfiguration getBeetlGroupUtilConfiguration() { BeetlGroupUtilConfiguration beetlGroupUtilConfiguration = new BeetlGroupUtilConfiguration(); //獲取Spring Boot 的ClassLoader ClassLoader loader = Thread.currentThread().getContextClassLoader(); if(loader==null){ loader = BeetlConf.class.getClassLoader(); } beetlGroupUtilConfiguration.setConfigProperties(extProperties);//額外的配置,可以覆蓋默認配置,一般不需要 ClasspathResourceLoader cploder = new ClasspathResourceLoader(loader, templatesPath); beetlGroupUtilConfiguration.setResourceLoader(cploder); beetlGroupUtilConfiguration.init(); //如果使用了優化編譯器,涉及到字節碼操作,需要添加ClassLoader beetlGroupUtilConfiguration.getGroupTemplate().setClassLoader(loader); return beetlGroupUtilConfiguration; } @Bean(name = "beetlViewResolver") public BeetlSpringViewResolver getBeetlSpringViewResolver(@Qualifier("beetlConfig") BeetlGroupUtilConfiguration beetlGroupUtilConfiguration) { BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver(); beetlSpringViewResolver.setContentType("text/html;charset=UTF-8"); beetlSpringViewResolver.setOrder(0); beetlSpringViewResolver.setConfig(beetlGroupUtilConfiguration); return beetlSpringViewResolver; } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看