2、 关于导入maven项目javax.annotation.Nullable问题

本文介绍如何在项目中引入FindBugs包进行代码质量检查,包括依赖项的详细配置,帮助开发者有效发现潜在的代码缺陷。

1、这里需引入findbug包,默认的scope是test,可以根据情况修改

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.1</version>
</dependency>

<?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.rain4cloud</groupId> <version>1.0-SNAPSHOT</version> <artifactId>grpc-api</artifactId> <properties> <maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- 这里不需要手动设置 os.detected.classifier,插件会自动检测 --> <!--<os.detected.classifier>windows-x86_64</os.detected.classifier>--> <!--mac M暂未兼容,使用x86--> <os.detected.classifier>osx-x86_64</os.detected.classifier> <protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version> <protoc.version>3.25.3</protoc.version> <protobuf.java.version>3.25.3</protobuf.java.version> <grpc-java.version>1.70.0</grpc-java.version> </properties> <dependencies> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-stub</artifactId> <version>1.70.0</version> <exclusions> <exclusion> <groupId>javax.annotation</groupId> <artifactId>javax.annotation-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-protobuf</artifactId> <version>1.70.0</version> <exclusions> <exclusion> <groupId>javax.annotation</groupId> <artifactId>javax.annotation-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-api</artifactId> <version>1.70.0</version> </dependency> <!-- javax.annotation API --> <!-- <dependency>--> <!-- <groupId>javax.annotation</groupId>--> <!-- <artifactId>javax.annotation-api</artifactId>--> <!-- <version>1.3.2</version> <!– 使用最新版本或适合你项目的版本 –>--> <!-- </dependency>--> <!----> <dependency> <groupId>jakarta.annotation</groupId> <artifactId>jakarta.annotation-api</artifactId> <version>3.0.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.xolstice.maven.plugins</groupId> <artifactId>protobuf-maven-plugin</artifactId> <version>0.6.1</version> <configuration> <protocArtifact>com.google.protobuf:protoc:3.25.3:exe:${os.detected.classifier}</protocArtifact> <pluginId>grpc-java</pluginId> <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.70.0:exe:${os.detected.classifier}</pluginArtifact> </configuration> <executions> <execution> <goals> <goal>compile</goal> <goal>compile-custom</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>com.google.code.maven-replacer-plugin</groupId> <artifactId>replacer</artifactId> <version>1.5.3</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>replace</goal> </goals> </execution> </executions> <configuration> <includes> <include>**/*.java</include> </includes> <replacements> <replacement> <token>javax.annotation.Generated</token> <value>jakarta.annotation.Generated</value> </replacement> </replacements> </configuration> </plugin> </plugins> </build> </project>
07-16
Executing pre-compile tasks… Running 'before' tasks Checking sources Copying resources… [soms] Dependency analysis found 0 affected files Updating dependency information… [soms] Parsing java… [soms] java: 无法找到类型 'kotlin.jvm.internal.SourceDebugExtension' 的注释方法 'value()': 找不到kotlin.jvm.internal.SourceDebugExtension的类文件 java: 无法找到类型 'kotlin.jvm.internal.SourceDebugExtension' 的注释方法 'value()' java: You aren't using a compiler supported by lombok, so lombok will not work and has been disabled. Your processor is: org.jetbrains.jps.javac.$Proxy8 Lombok supports: sun/apple javac 1.6, ECJ java: 来自注释处理程序 'org.mapstruct.ap.MappingProcessor' 的受支持 source 版本 'RELEASE_6' 低于 -source '1.8' java: 没有处理程序要使用以下任何注释: com.fasterxml.jackson.annotation.JsonProperty,org.springframework.data.repository.query.Param,org.springframework.web.bind.annotation.RequestParam,org.mapstruct.Mapping,net.sf.jasperreports.functions.annotations.FunctionCategory,org.springframework.beans.factory.annotation.Autowired,javax.validation.constraints.NotEmpty,javax.validation.Valid,org.apache.ibatis.type.MappedJdbcTypes,org.springframework.stereotype.Repository,org.springframework.web.bind.annotation.PostMapping,javax.annotation.Resource,javax.validation.constraints.Pattern.List,javax.validation.constraints.NotNull,org.springframework.web.bind.annotation.RestController,com.huawei.it.jalor5.core.annotation.JalorResource,io.swagger.v3.oas.annotations.tags.Tag,org.springframework.context.annotation.Lazy,io.swagger.v3.oas.annotations.responses.ApiResponses,com.alibaba.fastjson.annotation.JSONField,org.springframework.scheduling.annotation.EnableAsync,org.springframework.context.annotation.PropertySource,org.springframework.boot.context.properties.ConfigurationProperties,org.springframework.scheduling.annotation.Scheduled,org.springframework.context.annotation.Scope,org.springframework.web.bind.annotation.RequestBody,org.springframework.beans.factory.annotation.Value,io.swagger.v3.oas.annotations.Operation,org.springframework.stereotype.Service,org.springframework.web.bind.annotation.ExceptionHandler,javax.inject.Named,org.springframework.scheduling.annotation.EnableScheduling,javax.annotation.Nullable,org.springframework.web.bind.annotation.ControllerAdvice,org.springframework.validation.annotation.Validated,org.apache.ibatis.annotations.Param,org.springframework.boot.autoconfigure.SpringBootApplication,javax.xml.bind.annotation.XmlRootElement,org.apache.ibatis.type.Alias,com.huawei.it.jalor5.core.annotation.NoJalorTransation,com.huawei.it.jalor5.core.annotation.JalorOperation,org.apache.logging.log4j.core.config.plugins.validation.constraints.NotBlank,com.huawei.it.isrp.common.config.retry.Retryable,org.springframework.web.bind.annotation.PathVariable,javax.validation.constraints.Size,javax.validation.constraints.Min.List,org.springframework.web.bind.annotation.PutMapping,org.mapstruct.Mapper,com.fasterxml.jackson.annotation.JsonAlias,javax.ws.rs.DefaultValue,javax.validation.constraints.Max,org.apache.ibatis.annotations.MapKey,org.springframework.data.annotation.Transient,org.springframework.web.bind.annotation.DeleteMapping,io.swagger.v3.oas.annotations.media.Schema,javax.validation.constraints.Min,org.apache.ibatis.type.MappedTypes,com.fasterxml.jackson.annotation.JsonFormat,com.google.gson.annotations.SerializedName,io.swagger.v3.oas.annotations.Parameter,org.springframework.context.annotation.Configuration,org.jetbrains.annotations.Nullable,javax.validation.constraints.Pattern,org.apache.ibatis.annotations.Mapper,javax.annotation.PostConstruct,org.springframework.web.bind.annotation.RequestHeader,org.jetbrains.annotations.NotNull,org.hibernate.validator.constraints.Length,org.springframework.scheduling.annotation.Async,org.mapstruct.Mappings,javax.validation.constraints.NotBlank,javax.validation.constraints.Size.List,org.springframework.web.bind.annotation.RequestMapping,javax.validation.constraints.DecimalMin,org.hibernate.validator.constraints.Range,java.lang.FunctionalInterface,javax.inject.Inject,net.sf.jasperreports.functions.annotations.FunctionCategories,com.fasterxml.jackson.annotation.JsonIgnore,org.springframework.beans.factory.annotation.Qualifier,org.springframework.web.bind.annotation.GetMapping,net.sf.jasperreports.functions.annotations.Function,org.springframework.web.bind.annotation.ResponseBody,net.sf.jasperreports.functions.annotations.FunctionParameters,org.springframework.stereotype.Component,javax.validation.constraints.DecimalMax,com.fasterxml.jackson.annotation.JsonInclude,org.springframework.context.annotation.Bean,com.google.common.annotations.VisibleForTesting,org.springframework.transaction.annotation.Transactional Dependency analysis found 0 affected files Errors occurred while compiling module 'soms' javac 8 was used to compile java sources Finished, saving caches… Compilation failed: errors: 1; warnings: 17 Executing post-compile tasks… Synchronizing output directories… 2025/8/7 15:16 - Build completed with 1 error and 9 warnings in 6 sec, 749 ms 使用中文给出解决方案
08-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值