OpenAPI、SpringBoot 3.x并非所有内容都使用Jakarta而不是Javax

qvsjd97n  于 2023-01-05  发布在  Spring
关注(0)|答案(1)|浏览(301)

我正在尝试增加我的项目对SpringBoot 3.x的依赖性。当Spring从javax切换到jakarta时,我正在尝试让这一切也在项目中发生。我正在使用OpenAPI生成一些文件,对于大多数文件来说,一切都按预期运行,问题出在ApiUtils上-它仍然在尝试使用javax. servlet. http. HttpServletResponse。
我已经检查了mustache文件,那里没有javax依赖项。有什么想法如何处理这个问题吗?我将感激任何帮助。
我的部分pom连接到这个问题:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.1</version>
        <relativePath/>
    </parent>

    <properties>
        <jakarta.servlet-api.version>6.0.0</jakarta.servlet-api.version>
        <java.version>17</java.version>
        <springdoc-openapi-starter-webmvc-ui.version>2.0.2</springdoc-openapi-starter-webmvc-ui.version>
    </properties>

 <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.openapitools</groupId>
                <artifactId>jackson-databind-nullable</artifactId>
                <version>${jackson-databind-nullable.version}</version>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok-mapstruct-binding</artifactId>
                <version>${lombok-mapstruct-binding.version}</version>
            </dependency>
            <dependency>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct</artifactId>
                <version>${mapstruct.version}</version>
            </dependency>
            <dependency>
                <groupId>org.mapstruct.extensions.spring</groupId>
                <artifactId>mapstruct-spring-annotations</artifactId>
                <version>${mapstruct-spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.mapstruct.extensions.spring</groupId>
                <artifactId>mapstruct-spring-extensions</artifactId>
                <version>${mapstruct-spring.version}</version>
            </dependency>
             <dependency>
                <groupId>jakarta.servlet</groupId>
                <artifactId>jakarta.servlet-api</artifactId>
                <version>${jakarta.servlet-api.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
                <version>${springdoc-openapi-starter-webmvc-ui.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-activemq</artifactId>
                <version>${spring-boot-starter-activemq.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!--Spring dependencies-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-ldap</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-json</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-jms</artifactId>
        </dependency>
         <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
        </dependency>
    </dependencies>
lx0bsm1f

lx0bsm1f1#

这是一个known issue,实际上昨天通过合并修复了它,现在,您可以使用新的useJakartaEe配置选项来强制Jakarta导入。

*Maven示例 *

<configOptions>
  <useJakartaEe>true</useJakartaEe>
</configOptions>

* 分级示例 *

configOptions = [
  useJakartaEe: "true"
]

*CLI示例 *

openapi-generator -g spring -o out -i spec.yaml --additional-properties=useJakartaEe=true

相关问题