码迷,mamicode.com
首页 > 编程语言 > 详细

Spring Boot遇上jello

时间:2015-08-15 20:10:25      阅读:498      评论:0      收藏:0      [点我收藏+]

标签:

开篇准备:

你得有准备jello(FIS-java解决方案),npm,maven.

开整:

  1. 编写maven配置文件

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.example</groupId>
        <artifactId>spring-io</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <fastjson.version>1.2.4</fastjson.version>
            <guava.version>18.0</guava.version>
        </properties>
    
        <parent>
            <groupId>io.spring.platform</groupId>
            <artifactId>platform-bom</artifactId>
            <version>2.0.0.BUILD-SNAPSHOT</version>
            <relativePath/>
        </parent>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-velocity</artifactId>
            </dependency>
            <dependency>
                <groupId>com.baidu.fis.velocity</groupId>
                <artifactId>fis-velocity-tools</artifactId>
                <version>1.8</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>${fastjson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>
            <dependency>
                <groupId>xstream</groupId>
                <artifactId>xstream</artifactId>
                <version>1.2.2</version>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
            </dependency>
            <dependency>
                <groupId>ognl</groupId>
                <artifactId>ognl</artifactId>
                <version>3.0.11</version>
            </dependency>
        </dependencies>
    
        <repositories>
            <repository>
                <id>spring-snapshots</id>
                <url>http://repo.spring.io/libs-snapshot</url>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
    
        <pluginRepositories>
            <pluginRepository>
                <id>spring-snapshots</id>
                <url>http://repo.spring.io/libs-snapshot</url>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <useSystemClassLoader>false</useSystemClassLoader>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
    </project>
  2. 编写启动类

    package com.hstart;
    
    import com.baidu.fis.velocity.spring.FisBean;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.annotation.Bean;
    import org.springframework.web.filter.CharacterEncodingFilter;
    
    import javax.servlet.Filter;
    
    /**
     * @author daihy
     * @since 2015/7/15
     */
    @SpringBootApplication
    public class Application {
    
        @Bean
        public Filter characterEncodingFilter() {
            CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
            characterEncodingFilter.setEncoding("UTF-8");
            characterEncodingFilter.setForceEncoding(true);
            return characterEncodingFilter;
        }
    
        @Bean
        public FisBean fisBean(){
            return new FisBean();
        }
    
        public static void main(String[] args) throws Exception {
            SpringApplication.run(Application.class, args);
        }
    
    }
  3. 配置velocity和其他参数

    技术分享

    被YAML坑了一回,第一次用,分层结构不能使用Tab字符,否则等着哭吧

  4. 运行

    然后你就可以愉快的在浏览器敲上localhost:8080就能看到spring-boot启动了,我启动时是这样的,你启动的时候也会是这样的?

  5. Game Over

    打开页面ζ 最后是这样的,后面会介绍jello velocity的开发和一些细节

    技术分享

Spring Boot遇上jello

标签:

原文地址:http://my.oschina.net/luoyezhiqiu/blog/492978

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!