Spring-boot 常遇到的问题

1、org.xml.sax.SAXParseException: 元素类型 "meta" 必须由匹配的结束标记 "" 终止。

解决办法:页面标签少了结束标签


2、Spring-JPA更新对象信息方法:

数据库查询出对象,copy对象,过滤需要修改的字段"name","code","stateTime"

BeanUtils.copyProperties(roleService.findRoleById(role.getId()), role,

"name","code","stateTime”);


3.Error resolving template “home”, template might not exist or might not be accessible by any of the configured Template Resolvers

问题说明:不存在home文件或目录配置错误

解决办法:需要创建一个html页面名叫home.html;或配置路径

spring:

  thymeleaf:

    cache:true

    prefix:classpath:/templates/

    mode:HTML5


4. nested exception is java.lang.IllegalArgumentException: No session repository could be auto-configured, check your configuration (session store type is 'null’)

edit  configuration中

name填写:spring.profiles.active

value填写:local



5.restTemplate 报错 No instances available for ip

解决办法:访问ip:Create a new RestTemplate instead of autowiring it.

重新new一个RestTemplate对象实例


6.Spring-Boot无限自动重启

解决办法:删除方法spring-boot-devtools-1.5.1.RELEASE.jar


7.跨域问题

在Controller上面添加注解@CrossOrigin,就能提供跨域请求

import org.springframework.web.bind.annotation.CrossOrigin;


8.无法识别以POST方式请求的body数据

在Controller或者方法上的RequestMapping注解上加上字段consumes,则可支持body提交

consumes= MediaType.APPLICATION_JSON_VALUE

MediaType类名全路径:org.springframework.http.MediaType

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容