如何验证 Spring feature/Bug 修复在我使用的 Spring 引导版本中可用?

How to verify a Spring feature/Bug fix is available in the Spring boot version which i am using?

我正在开发一个 spring 批处理程序来处理来自 sql 的数据并写入 xml。我使用 staxEventItemWriter 来做到这一点。但是由于这个问题 https://jira.spring.io/browse/BATCH-1377 我无法解决名称空间问题。当我们查看此 Jira 卡上的评论时,它说它已在 2010 年修复。但它在我使用的最新 spring 引导版本中不可用。我尝试使用 Jira 卡中描述的补丁 class,它对我来说工作正常。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.demo.sitemap</groupId>
    <artifactId>SqlToXml</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>SqlToXml</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-batch</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.batch</groupId>
            <artifactId>spring-batch-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>6.1.0.jre8</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework/spring-oxm -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>3.0.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.10</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.0.4.RELEASE</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

How to verify a Spring feature/Bug fix is available in the Spring boot version which i am using?

您正在使用 Spring Boot 2.0.4.RELEASE。这将带来 Spring 批处理版本 4.0.1.RELEASE。您可以使用 Spring Boot Initializr REST API.

找到有关依赖项的更多详细信息

问题 BATCH-1377 在版本 2.1.0.RC1 中被标记为已解决并且在 4.0 中也可用。1.RELEASE。

But its not available in the latest spring boot versions which i am using. i tried with the patch class described in the Jira card its working fine for me.

贡献者建议的补丁使用了额外的 属性 rootTagNamePrefix 但这是根据 this comment to use the naming convention {uri}prefix:root in order to be consistent with Spring WS. The issue was fixed here: https://github.com/spring-projects/spring-batch/commit/f56ee747296961917caa38fa9e14785dafc0b18b

修改的

所以在你的情况下,如果你想将命名空间添加到根标签,你需要使用这个命名约定。请参阅此处的示例:https://github.com/spring-projects/spring-batch/blob/f56ee747296961917caa38fa9e14785dafc0b18b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java#L287