1.使用jsp返回
application.properties
############## OAuth ################
server.port=8082
#jsp path
spring.view.prefix=/WEB-INF/page/
spring.view.suffix=.jsp
依赖包
<dependency>
<groupId>apache-taglibs</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<!-- jsp解析器 -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
启动方法
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RestController;
//@SpringBootApplication
@PropertySource("classpath:application.properties")
// @EnableTransactionManagement(proxyTargetClass = true)
@ImportResource({ "classpath*:springContext.xml" })
@ComponentScan("com.zy")
// @EnableAutoConfiguration
@RestController
@EnableAutoConfiguration
public class RumTimeBox {
public static void main(String[] args) {
SpringApplication.run(RumTimeBox.class, args);
System.out.println("success!");
}
protected SpringApplicationBuilder config(SpringApplicationBuilder applicationBuilder) {
return applicationBuilder.sources(RumTimeBox.class);
}
}
2.springboot 与freemarker
配置文件application.properties
############## OAuth ################
server.port=8082
#jsp path
#spring.view.prefix=/WEB-INF/page/
#spring.view.suffix=.html
spring.freemarker.checkTemplateLocation=false
spring.freemarker.suffix=.html
spring.freemarker.template-loader-path=/WEB-INF/page/
依赖包
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.25-incubating</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
启动方法
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RestController;
//@SpringBootApplication
@PropertySource("classpath:application.properties")
// @EnableTransactionManagement(proxyTargetClass = true)
@ImportResource({ "classpath*:springContext.xml" })
@ComponentScan("com.zy")
// @EnableAutoConfiguration
@RestController
@EnableAutoConfiguration
public class RumTimeBox extends SpringBootServletInitializer {
/**
* springboot默认启动
*
* @param args
*/
public static void main(String[] args) {
SpringApplication.run(RumTimeBox.class, args);
System.out.println("success!");
}
/**
* 重写启动方法,用于使用第三方配置如jetty 启动时使用
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(RumTimeBox.class);
}
}
springboot配置文件中只有配置注解扫描<context:component-scan base-package="com.zy" />