SpringBoot项目的云服务器部署地址:http://blog.csdn.net/wchstrife/article/details/76725317
SpringBoot项目的云服务器部署 http://blog.csdn.net/zhangxing52077/article/details/73008359
主要内容:
pom.xml添加或者修改
<build>
<finalName>自定义名字</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestone</id>
<url>http://repo.spring.io/libs-release</url>
</repository>
</repositories>
我想先直接把这个网站部署到我的服务器上,因为还没弄过.
这个Blog在IDEA上运行的挺好的,但是上传到服务器上,没法访问,于是在windows本地用java -jar 命令进行测试,
jar包运行正常,但是在localhost:8080/blog/admin/login时,就会出现以下的报错
Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "admin/login/", template might not exist or might not be accessible by any of the configured Template Resolvers
网上找了找解决办法,虽然没有解决,但是在这里分享下:
原因是指向模板的路径前有斜杆/,就会出错,去掉就正常了(路径前不能带斜杆,类似相对路径的写法)
在application.properties配置文件添加
spring.thymeleaf.prefix=classpath:/templates/
使用springboot的过程中,如果使用thymeleaf作为模板文件,则要求HTML格式必须为严格的html5格式,必须有结束标签,否则会报错!解决办法如下:
1、你可以使用严格的标签,也就是每个标签都有结束标签,这种可能比较麻烦
2、在application.properties中增加spring.thymeleaf.mode=LEGACYHTML5,即声明thymeleaf使用非严 格的html。
maven依赖如下
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>