- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我想大张旗鼓地记录我的项目。我在我的项目中添加了 swagger 注释和 io.springfox 依赖项,但是当我运行 mvn clean package
时,我遇到了很多错误:
PS D:\parent-project> mvn clean package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent-project [pom]
[INFO] module-common-lib [jar]
[INFO] module1 [jar]
[INFO] module2 [jar]
[INFO]
[INFO] ------------< parent-project:parent-project >-------------
[INFO] Building parent-project 0.0.1-SNAPSHOT [1/4]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ parent-project ---
[INFO]
[INFO] -------< parent-project:module-common-lib >-------
[INFO] Building module-common-lib 0.0.1-SNAPSHOT [2/4]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ module-common-lib ---
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ module-common-lib ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\parent-project\module-common-lib\src\main\resources
[INFO] skip non existing resourceDirectory D:\parent-project\module-common-lib\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ module-common-lib ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to D:\parent-project\module-common-lib\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[6,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[7,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[9,2] cannot find symbol
symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[4,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[5,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[5,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[6,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[8,2] cannot find symbol
symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[7,2] cannot find symbol
symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[4,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[5,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[7,2] cannot find symbol
symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[31,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.ResponseInfo
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[40,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.ResponseInfo
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[49,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.ResponseInfo
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[13,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.HelloWorldResponse
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[13,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.ResponseSimple
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[14,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.HelloWorldMessageResponse
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[23,10] cannot find symbol
symbol: class ApiModelProperty
location: class com.company.lab.microservices.common.api.HelloWorldMessageResponse
[INFO] 19 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent-project 0.0.1-SNAPSHOT ............... SUCCESS [ 0.156 s]
[INFO] module-common-lib ................... FAILURE [ 1.530 s]
[INFO] module1 ..................... SKIPPED
[INFO] module2 0.0.1-SNAPSHOT ...... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.910 s
[INFO] Finished at: 2018-09-18T09:39:17+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project module-common-lib: Compilation failure: Compilation failure:
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[6,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[7,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[9,2] cannot find symbol
[ERROR] symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[4,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[5,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[5,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[6,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[8,2] cannot find symbol
[ERROR] symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[7,2] cannot find symbol
[ERROR] symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[4,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[5,30] package io.swagger.annotations does not exist
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[7,2] cannot find symbol
[ERROR] symbol: class ApiModel
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[31,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.ResponseInfo
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[40,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.ResponseInfo
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseInfo.java:[49,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.ResponseInfo
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldResponse.java:[13,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.HelloWorldResponse
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/ResponseSimple.java:[13,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.ResponseSimple
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[14,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.HelloWorldMessageResponse
[ERROR] /D:/workspace/parent-project/module-common-lib/src/main/java/com/company/lab/microservices/common/api/HelloWorldMessageResponse.java:[23,10] cannot find symbol
[ERROR] symbol: class ApiModelProperty
[ERROR] location: class com.company.lab.microservices.common.api.HelloWorldMessageResponse
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :module-common-lib
在这个项目中,module1 和 module2 都使用 common-lib 来使用 JSON 作为响应类型,并使用 swagger 创建文档。
结构项目:
parent-project
pom.xml
module-common-lib
pom.xml
src/main/java
module1
src/main/java
src/main/resources
pom.xml
module2
src/main/java
src/main/resources
pom.xml
Pom.xml - 父项目:
<?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">
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<packageClassifier>exec</packageClassifier>
<spring-boot.version>1.5.9.RELEASE</spring-boot.version>
<spring-cloud.version>1.4.4.RELEASE</spring-cloud.version>
<springfox-swagger.version>2.6.1</springfox-swagger.version>
</properties>
<dependencyManagement>
<dependencies>
.....
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module-common-lib</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-swagger.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
Pom.xml - 模块通用库
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
</project>
带有 swagger 注释的类之一(其他类具有相同的注释但代码不同):
import java.io.Serializable;
import java.util.Optional;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel
public class ResponseSimple implements Serializable {
transient private static final long serialVersionUID = 5106222175899418836L;
private ResponseInfo responseInfo = new ResponseInfo();
@ApiModelProperty(notes = "Response info")
public ResponseInfo getResponseInfo() {
return responseInfo;
}
public void setResponseInfo(ResponseInfo responseInfo) {
this.responseInfo = responseInfo;
}
@Override
public String toString() {
return Optional.of(responseInfo).map(ri -> ri.toString()).orElse("");
}
}
我有 Maven 3.5.4
有谁知道为什么它不起作用?
最佳答案
在你的module-common-lib/pom.xml
文件,你只引用 io.springfix:springfox-swagger2
<dependencyManagement>
中的依赖项元素。
在子 POM 中,<dependencies>
元素不需要位于 <dependencyManagement>
内元素,因为您正在使用依赖项(不仅仅是管理其版本、范围、排除项等以供后续使用——这是父 POM 所做的)。
基本上事实是依赖io.springfox:springfox-swagger2
仅在 <dependencyManagement>
部分意味着它(更重要的是,它的传递依赖项 io.swagger:swagger-annotations
包含 io.swagger.annotations
包)未添加到编译类路径。
您可以通过运行 mvn dependency:build-classpath
来验证这一点查看 Maven 构建的类路径。
解决方法是删除行 <dependencyManagement>
和 </dependencyManagement>
在 module-common-lib/pom.xml
(但 NOT 来自 parent-project/pom.xml
,该元素用于其预期目的)。
关于java - Maven: 包 io.swagger.annotations 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52392273/
我试图在我的微服务项目中生成一个单一的 swagger,在 Api 网关中将所有服务 swagger 聚合成一个单一的服务。为了实现这一点,我正在学习下一个教程 https://objectpartn
我的任务是将 Swagger 安装到 Web API 项目中。 已安装:来自 nuget 的最新版本的 Swashbuckle。 (Swashbuckle.Core.Net45 和 Swashbuck
我正在编写一个 swagger 规范,并且我有三个独立的端点。我如何在文档中将它们分开?我想明确区分示例:用户、帖子和其他。所以每个人都会有一个 CRUD 描述并显示在 swagger UI 中,它看
我试图在 Swagger 中定义一个查询参数,其中包含来自预定义项目集的逗号分隔字符串,例如 ?fruits=Apples,Oranges,Bananas但我从 swagger 编辑器收到以下错误 s
我正在使用 go-swagger 来生成 API 服务器。我注意到从 swagger.yml 生成的 json 被保存在 restapi/embedded_spec.go 中. 公开该 JSON 规范
我使用的是 springfox 版本 2.9.2 和 swagger 注释 1.5.x。 ApiModel 注释支持鉴别器、子类型和父属性,这些是使多态性工作所需的,但我没有看到生成的正确的 apid
我正在尝试使用本地 swagger.json 文件在 swagger 文档中显示。 我的 swagger.json 文件位于/home/user1/swagger-ui/dist/swagger.js
我们有一些数字字段,由于遗留原因,它们具有隐式长度限制。 给定一个长度限制为 5 的数字字段,显而易见的方法是将最大值设置为 99999,但是有没有办法在 swagger 规范中指定 1.111 可以
我们的项目为单个 API 使用多个 swagger 文件,但看起来 swagger-codegen 只接受一个。在这种情况下,我们如何使用 swagger-codegen 生成代码? 最佳答案 您可以
我正在尝试使用 https://github.com/swagger-api/swagger-codegen 生成 nodejs 客户端 sdk这是我使用的命令 swagger-codegen gen
我定义了一个以 MyObject 作为参数的路径。 MyObject 具有猫和狗的属性。这些有默认值。 在 swagger-editor 中,该示例不显示默认值,但试用确实创建了一个具有正确默认值的
我最近从 Swashbuckle 过渡到 Swagger-Net .进行更改后我遇到的一个问题是,现在我无法调用需要在 Authorization header 中发送 token 的 API。下面是
正在使用 AspNetCore 为使用 IIS 托管的 Web 应用程序设置 swagger。 .json 页面加载并且似乎可以很好地接触所有 API,但是当导航到 {localhost}/swagg
我想将任何复杂的 swagger-API-document(swagger.json) 解析为 Java 对象。 可能是列表> 有哪些可用选项? 我正在尝试使用 io.swagger.parser.S
我要将我的 API 服务器集成到 Google Cloud Endpoints。 到目前为止,Google Cloud Endpoints 支持 swagger 2.0。 但是我的依赖项/库现在是 u
我是 swagger 的新手,发现有两个用于 swagger 注释的包:io.swagger.annotations 和 com.wordnik.swagger.annotations。我想知道它们之
好的,我有许多 io.swagger.models.Swagger 对象,我已将它们合并到一个新的 super Swagger 中。现在我想要 super html。我怎样才能得到这个?请注意,为了获
我们当前的部署模式要求我手动编写 swagger json 输出,该输出将由我公司使用的基于 Swagger 的 UI 使用。我希望我正在编写的 json 能够提供“默认”值来填充所有输入字段(包括
我有以下 HTTP 触发的 Azure 函数。我已经使用此链接为我的端点设置了 Swagger here .以下 API 需要一组查询字符串参数,即 "name"、"email"、"phone",因此
我正在努力让 Swagger 正确呈现我的 ServiceStack 服务。 我希望看到一个 UserId 字符串作为表单参数,一个 PrivateCustomer 对象作为主体参数,但是尽管 Use
我是一名优秀的程序员,十分优秀!