开篇准备:
你得有准备jello(FIS-java解决方案),npm,maven.
开整:
编写maven配置文件
4.0.0 com.example spring-io 1.0.0-SNAPSHOT UTF-8 1.2.4 18.0 io.spring.platform platform-bom 2.0.0.BUILD-SNAPSHOT org.springframework spring-core org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-velocity com.baidu.fis.velocity fis-velocity-tools 1.8 com.alibaba fastjson ${fastjson.version} com.google.guava guava ${guava.version} xstream xstream 1.2.2 junit junit 4.12 ognl ognl 3.0.11 spring-snapshots http://repo.spring.io/libs-snapshot true spring-snapshots http://repo.spring.io/libs-snapshot true org.springframework.boot spring-boot-maven-plugin org.apache.maven.plugins maven-surefire-plugin false 编写启动类
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 */@SpringBootApplicationpublic 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); }}
配置velocity和其他参数
被YAML坑了一回,第一次用,分层结构不能使用Tab字符,否则等着哭吧
运行
然后你就可以愉快的在浏览器敲上localhost:8080就能看到spring-boot启动了,我启动时是这样的,你启动的时候也会是这样的♥
Game Over
打开页面ζ 最后是这样的,后面会介绍jello velocity的开发和一些细节