我的任务是升级集线器中的一个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依赖项,但我找不到罪魁祸首.
换句话说,一切都正常,但如果这件小事在以后的生产中造成任何问题,我会很讨厌的.我判断了其他已经迁移的服务,我认为这些服务中没有任何一个会发生这种情况.
谢谢你的建议.