最近在采用SpringBoot集成Jersey来构建Restful服务时,遇到无法访问静态资源的问题。经过排查发现是Jersey的ApplicationPath默认为”/”,这样一来就会拦截所有的请求而导致无法访问静态资源。
解决如下:
配置属性文件:application.yml; 内容如下: server: port: 8080 spring: datasource: name: easyui url: jdbc:mysql://10.10.128.117:3306/easyui?useUnicode=true&characterEncoding=utf8 username: root password: root driver-class-name: com.mysql.jdbc.Driver mybatis: mapper-locations: classpath:mapping/*Mapper.xml type-aliases-package: com.ieds.springbootmybatis.pojo jersey: spring.jersey.application-path: rest
配置完成后:
浏览器输入:
http://localhost:8080/rest/userMgr/getAllUsers; 访问形式:http:host:port/rest