我的任务是升级集线器中的一个REST服务,使其使用SpringBoot3.其中,我删除了所有的javax导入,代之以Jakarta导入. 但是,当我把我的应用程序打包时,我在其中一个生成的文件中得到了一个javax导入.

具体地说,导入位于这个生成的类中(如果这个类的实现对于解决问题很重要,我将添加它):

import cz.cvut.fel.czm.api.dto.NotificationGetDTO;
import cz.cvut.fel.czm.api.dto.NotificationPostDTO;
import cz.cvut.fel.czm.model.notification.Notification;
import java.time.LocalDateTime;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2023-08-30T15:34:27+0200",
    comments = "version: 1.5.5.Final, compiler: javac, environment: Java 17.0.2 (Oracle Corporation)"
)
@Component
public class NotificationMapperImpl implements NotificationMapper {

...
}

这是实际的 map 绘制程序:

import cz.cvut.fel.czm.api.dto.NotificationGetDTO;
import cz.cvut.fel.czm.api.dto.NotificationPostDTO;
import cz.cvut.fel.czm.model.notification.Notification;
import org.mapstruct.Mapper;

import java.time.LocalDateTime;

@Mapper(componentModel = "spring", imports = {LocalDateTime.class})
public interface NotificationMapper {
    NotificationGetDTO toDTO(Notification notification);

    Notification toModel(NotificationPostDTO notificationPostDTO);
}

我使用的是服务的自定义父级,因此我不负责更改依赖项的版本.但父文件中的某个地方也可能存在错误.

这是我在POM中的映射 struct 依赖项:

        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
        </dependency>

这是我正在使用的maven插件配置:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${org.projectlombok.lombok.version}</version>
                        </path>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${org.mapstruct.mapstruct.version}</version>
                        </path>
                    </annotationProcessorPaths>
                    <compilerArgs>
                        <compilerArg>-Amapstruct.defaultComponentModel=spring</compilerArg>
                    </compilerArgs>
                </configuration>
            </plugin>

我判断了一下,我们使用的mapstruct版本是1.5.5最终版.

似乎当我在本地运行服务时,端点是可用的并且正在工作,当我通过InSomnia访问它们时,但当我在InteliJIDEA中打开它时,我遇到了 "javax.madement.InstanceNotFoundException:orh.springFrawork.ot:type=Endpoint,Name=Mappings,*" 留言.

我try 了硬编码mapstruct依赖项的版本,但这似乎不是问题的原因. 我还研究了哪些其他依赖项可能导致javax依赖项,但我找不到罪魁祸首.

换句话说,一切都正常,但如果这件小事在以后的生产中造成任何问题,我会很讨厌的.我判断了其他已经迁移的服务,我认为这些服务中没有任何一个会发生这种情况.

谢谢你的建议.

推荐答案

所以,我发现这根本不是一个基于代码的问题. 我仍然不确定为什么会发生这种情况,但我卸载了IDE并安装了新版本的IntellijIDEA.现在一切都运行得很好. 我的意思是,生成的注释不再使用javax依赖项,错误也不再显示.

谢谢你们的帮助.

Java相关问答推荐

Spring Webocket:尽管凭据设置为False,但MLhttpsify和Fetch请求之间的CORS行为存在差异

空手道比赛条件

Oracle DUAL表上使用DDL时jOOQ问题的解析'

最小拓Flutter 排序的时间复杂度是多少?

Springdoc Whitelabel Error Page with Spring V3

为什么我们不能实现两个接口,其中一个接口有相同的签名,其中一个接口有默认的实现在java?'

CAMEL 4中的SAXParseException

如何让JFileChooser(DIRECTORIES_ONLY)从FolderName中的空白开始?

只需最少的代码更改即可将版本号标记添加到日志(log)

在Java Swing Paint应用程序中捕获快速鼠标移动时遇到困难

在Java中,如何按一个属性升序,然后按另一个属性降序对对象列表进行排序?

返回响应时,CamelCase命名约定不起作用

JDK 21-为什么线程局部随机S nextInt不直接用Super.nextInt实现?

基于接口的投影、原生查询和枚举

GetChildren().emoveAll()不会删除 node

如何使用Criteria Builder处理一对多关系中的空值?

如何在Maven Central上部署?

AspectJ编织外部依赖代码,重新打包jar并强制依赖用户使用它

java构造函数中的冻结操作何时发生?

类型安全:从 JSONArray 到 ArrayList> 的未经判断的转换