简体   繁体   English

Spring Boot Maven 插件 – 排除所有依赖

[英]Spring Boot Maven Plugin – Exclude all dependencies

In my current project I'm using spring boot i want to exclude all dependencies.在我当前的项目中,我正在使用 spring boot 我想排除所有依赖项。

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>1.3.3.RELEASE</version>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <mainClass>a.b.testClass</mainClass>
        <layout>ZIP</layout>
          <excludeArtifactIds>*</excludeArtifactIds>
    </configuration>
</plugin>

Ugly solution that seems to work is to put includes with not existing artifact:似乎有效的丑陋解决方案是将包含与不存在的工件:

<configuration>
    <layout>ZIP</layout>
    <includes>
        <include>
            <groupId>abc</groupId>
            <artifactId>abc</artifactId>
        </include>
    </includes>
</configuration>

Works on version 1.3.3 but there is not guarantee it won't change in next versions.适用于 1.3.3 版,但不保证在下一版本中不会更改。

Or, you can package everything yourself, there are instructions for ant: http://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-build-an-executable-archive-with-ant that can give you list of steps that you need to apply in maven.或者,你可以自己打包所有东西,蚂蚁有说明: http : //docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-build-an-executable- archive-with-ant可以为您提供需要在 maven 中应用的步骤列表。 So:所以:

  1. Include Main Class and Start Class in manifest:在清单中包含 Main Class 和 Start Class:

     <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>org.springframework.boot.loader.PropertiesLauncher</mainClass> </manifest> <manifestEntries> <Start-Class>your.package.YourMainClass</Start-Class> </manifestEntries> </archive> </configuration> </plugin>
  2. Skip adding dependencies in lib directory.跳过在 lib 目录中添加依赖项。

  3. Add spring boot loader classes to the root: First you need dependency:将 spring boot loader 类添加到根目录:首先你需要依赖:

     <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-loader</artifactId> <version>1.3.3.RELEASE</version> </dependency>

    Then you need to unpack it:然后你需要解压它:

     <plugin> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <phase>process-sources</phase> <goals> <goal>unpack</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-loader</artifactId> <outputDirectory>${project.build.directory}/classes</outputDirectory> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin>

    There might be a better way to put loader classes in root, but this works ok for my project.可能有更好的方法将加载器类放在 root 中,但这对我的项目来说没问题。

You can try this one.你可以试试这个。

<configuration>
      <excludes>
        <exclude>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclude>
      </excludes>
    </configuration>

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

相关问题 maven-shade-plugin:排除依赖项及其所有传递依赖项 - maven-shade-plugin: exclude a dependency and all its transitive dependencies Spring Boot Maven插件:从最终的jar中排除属性文件 - Spring Boot Maven Plugin: Exclude properties file from final jar spring-boot-maven-plugin 创建具有依赖项的 jar - spring-boot-maven-plugin create jar with dependencies Spring 引导核心依赖项被 maven-dependency-plugin 视为未使用 - Spring boot core dependencies seen as unused by maven-dependency-plugin 使用spring boot和spring-boot-maven-plugin生成war时排除application.properties - Exclude application.properties when generating war using spring boot and spring-boot-maven-plugin Spring Boot 中的 Maven 依赖问题 - Maven dependencies issues in Spring Boot Spring Boot (Maven) 中的不兼容依赖项 - Incompatible dependencies in Spring Boot (Maven) spring-boot:排除对包装的依赖性 - spring-boot : Exclude dependencies on packaging 如何从 maven 程序集插件中排除依赖项:jar-with-dependencies? - How to exclude dependencies from maven assembly plugin : jar-with-dependencies? 插件 org.springframework.boot:spring-boot-maven-plugin:1.3.0.BUILD-SNAPSHOT 或其依赖项之一无法解析 - Plugin org.springframework.boot:spring-boot-maven-plugin:1.3.0.BUILD-SNAPSHOT or one of its dependencies could not be resolved
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM