Springboot整合freemarker

来源:互联网 发布:mysql 命令行导入 编辑:程序博客网 时间:2024/06/05 20:08
Springboot中不推荐使用jsp。所以表现层页面可以使用freemarker来实现。
在pom文件中添加对freemarker启动器的依赖
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-freemarker</artifactId>
        </dependency>
模板必须放到src/main/resources/templates目录下。模板扩展名必须为ftl
网页中可能会用到,图片、css、js等静态资源。
需要把静态资源放到src/main/resources下的static目录下


Springboot的部署
Jar包是一个fat jar。其中包含项目要运行使用的所有的jar包。
第一步:在工程的pom.xml中添加以下依赖
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

第二步:可以直接使用maven的命令打成jar包。
mvn package
第三步:java -jar spring-boot-first-0.0.1-SNAPSHOT.jar
原创粉丝点击