application作为maven依赖

application作为maven依赖

本文介绍了spring boot application作为maven依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的Spring启动应用程序,我希望在我的其他项目中作为依赖项。我想使用spring boot应用程序中的类。

I have an existing spring boot application that I would like to have as a dependency in my other project. I want to use classes from the spring boot application.

Maven下载工件和所有检出但是intellij和eclipse无法找到类。

Maven downloads the artifact and all checks out but intellij and eclipse can't find the classes.

当我深入了解外部库时,我会在jar内的BOOT-INF文件夹中找到所有类。其他罐子的包装在罐子的根部,所以我认为这是问题所在。

When I dig in to the external libs I find all classes in the "BOOT-INF" folder inside of the jar. Other jars have their packages in the root of the jar, so I figure this is the problem.

我能做些什么来解决这个问题?

What can I do fix this?

我可以在原来的春季启动应用程序中更改内容。

I can change stuff in the original spring boot application.

推荐答案

这包含在 Spring Boot的文档。简而言之,您需要将构建配置为对重新打包的胖jar使用分类器,以便您可以将原始jar用作依赖项:

This is covered in Spring Boot's documentation. In a nutshell, you need to configure your build to use a classifier for the repackaged fat jar so that you can use the original jar as a dependency:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <classifier>exec</classifier>
            </configuration>
        </plugin>
    </plugins>
</build>

这篇关于spring boot application作为maven依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 20:38