您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

使用JRebel 6.0.0进行部署时,在Spring 4.1.2更新之后找不到资源

使用JRebel 6.0.0进行部署时,在Spring 4.1.2更新之后找不到资源

(我无法在当前的JRebel 6.1.1中重现 )-我猜 已修复(2014年12月23日)

修复了Spring ResourceHttpRequestHandler无法为webroot之外的资源提供服务的问题。

(JRebel Changeloghttps://zeroturnaround.com/software/jrebel/download/changelog/6-x/

对于感兴趣的人如何解决它:

我只能猜测,因为这很奇怪。Spring 4.1.6(即我用于测试的版本)的类org.springframework.web.servlet.resource.PathResourceResolver具有方法checkResource(Resource resource, Resource location)

protected boolean checkResource(Resource resource, Resource location) throws IOException {
    if (isResourceUnderLocation(resource, location)) {
        return true;
    }
    if (getAllowedLocations() != null) {
        for (Resource current : getAllowedLocations()) {
            if (isResourceUnderLocation(resource, current)) {
                return true;
            }
        }
    }
    return false;
}

第一种ifisResourceUnderLocation...检查请求是否正在访问已配置资源文件夹之外的资源的方法

isResourceUnderLocation(Resource resource, Resource location) {
    ...
    resourcePath = ((ServletContextResource) resource).getPath();
    locationPath = StringUtils.cleanPath(((ServletContextResource) location).getPath());
    ...
    if (!resourcePath.startsWith(locationPath)) {
        return false;
    }
    ...
 }

当我使用调试器检查JRebel处于活动状态时,发生了什么事情时,发生了一些奇怪的事情:当JVM上线时if (isResourceUnderLocation(resource, location)) {,该方法isResourceUnderLocation就不会被调用

因此,我得出的结论是,JRebel进行了一些字节码操作,以防止执行检查(以及整个isResourceUnderLocation方法)。

Java 2022/1/1 18:13:44 有721人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶