??Spring Boot常见问题

热部署不生效

配置方法
dev-tools详解

静态资源文件不加载

1.首先配置静态资源目录
spring:
datasource:
url: jdbc:mysql://localhost:3306/test?characterEncoding=utf-8&serverTimezone=UTC
username: test
password: 111111
driver-class-name: com.mysql.cj.jdbc.Driver
resources:
static-locations: classpath:/templates/,classpath:/resources/,classpath:/static/,classpath:/views/
2.注意配置了资源目录后如:classpath:/templates,那么templates就不能再写到路径里了。
3.遇到一个问题是,在controller类上面加了@RequestMapping(“test”)后,就无法访问到静态资源了。因为路径里默认加了个test

其他日志框架统一到slf4j

1.剔除日志框架,替换为对应的slf4j提供的替换包。在官网有。

java.lang.IllegalArgumentException: Result Maps collection already contains value

多次运行generator插件。可能导致产生了重复数据。

解决方法 然后删除了mapper.xml,model,以及mapper接口后,重新运行插件后正常。

分页插件pagehelper不起作用

后来发现是版本整的太高了,springboot照样存在版本兼容问题啊。这个版本搞起来后,轻易不要动啊。

<dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
            <version>5.1.2</version>
        </dependency>

改成下面版本就好用了

<dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
            <version>4.1.3</version>
        </dependency>

Parameter0notfound.Availableparametersare[arg1,arg0,param1,param2]的解决方法

错误:Parameter '0' not found.Available parameters are [arg1, arg0, param1, param2]的解决方法

调用的方法:

  List<Card> temp = cardService.queryRepeat(Type,shop);
   <select id="queryRepeat" parameterType="String" resultType="Card">

      select * from card where card_type=#{type} and shop=#{shop}

   </select> 

此時报错:Parameter '0' not found.Available parameters are [arg1, arg0, param1, param2]
解决方法:

  <select id="queryRepeat" parameterType="String" resultType="Card">

      select * from card where card_type=#{arg0} and shop=#{arg1}

   </select>

SpringMVC 中ModelAndView用法

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

相关阅读更多精彩内容

友情链接更多精彩内容