简体   繁体   English

Swagger-core Scala依赖项过大

[英]Swagger-core Scala dependencies excessive size

I found that after I started using swagger documentation tool for my REST API, the size of my war file increased almost 4.5 times, from 8.7 MB to 39MB. 我发现在我开始为我的REST API使用swagger文档工具之后,我的war文件的大小增加了近4.5倍,从8.7 MB增加到39MB。 I am using Maven to build the project. 我正在使用Maven来构建项目。

That is because of the Swagger Scala dependencies big size, specially scala-compiler. 这是因为Swagger Scala依赖大尺寸,特别是scala编译器。 So I was trying to find out which of those dependencies are not really needed. 所以我试图找出哪些依赖项并不是真正需要的。 I created a new issue in the project's Github page: https://github.com/wordnik/swagger-core/issues/624 They answered that it is not a good idea to remove any scala dependency as the framework is written in that language and that could break it. 我在项目的Github页面中创建了一个新问题: https//github.com/wordnik/swagger-core/issues/624他们回答说删除任何scala依赖项不是一个好主意,因为框架是用该语言编写的这可能会破坏它。 Also recommended as a workaround to put the dependencies in the container/server instead of inside the war. 还建议将依赖项放在容器/服务器而不是战争中。

After doing some trial and error work, I found that it is possible to remove some dependencies without breaking it. 在做了一些试验和错误工作之后,我发现可以在不破坏它的情况下删除一些依赖项。 So far after almost one month of use, the documentation tool seems to work properly. 经过近一个月的使用,文档工具似乎正常运行。 These are the dependencies I removed: 这些是我删除的依赖项:

    <dependency>
        <groupId>com.wordnik</groupId>
        <artifactId>swagger-jersey2-jaxrs_2.10</artifactId>
        <version>${swagger-jersey.version}</version>
        <exclusions>
            <exclusion>
                <artifactId>jackson-module-scala_2.10</artifactId>
                <groupId>com.fasterxml.jackson.module</groupId>
            </exclusion>
            <exclusion>
                <artifactId>scalap</artifactId>
                <groupId>org.scala-lang</groupId>
            </exclusion>
        </exclusions>
    </dependency>

This removes basically three big jars: scalap, scala-compiler and scala-reflect. 这基本上删除了三个大罐:scalap,scala-compiler和scala-reflect。 Which means almost 19 MB of reduced size. 这意味着大约19 MB的缩小尺寸。

I am not saying that you should not follow the advice of the developers from the Swagger team about not removing scala dependencies, but so far this has worked for me and wanted to share it. 我并不是说你不应该遵循Swagger团队开发人员关于不删除scala依赖关系的建议,但到目前为止,这对我有用,并且想要分享它。 I made my comments and closed the issue in Github as well: https://github.com/wordnik/swagger-core/issues/624 我发表了我的评论并在Github中关闭了这个问题: https//github.com/wordnik/swagger-core/issues/624

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM