简体   繁体   English

Spring Boot Maven插件

[英]Spring Boot Maven Plugin

I have two classes with main method and one loads the security configuration and the other does not. 我有两个使用main方法的类,一个类加载了安全性配置,而另一个则没有。 In order to create two artifacts - secure and non secure jars, I am doing something like the following : 为了创建两个工件-安全罐和非安全罐,我正在做以下事情:

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>1</id>
                        <configuration>

                            <mainClass>a.b.c.Secured</mainClass>
                            <finalName>secured</finalName>
                            <classifier>secured</classifier>
                        </configuration>
                    </execution>
                    <execution>
                        <id>2</id>
                        <configuration>

                            <mainClass>a.b.c.NonSecured</mainClass>
                            <finalName>non-secured</finalName>
                            <classifier>nonSecured</classifier>
                        </configuration>
                    </execution>
                </executions>

            </plugin>

        </plugins>

And I am seeing the exception - 我看到了例外-

java.lang.IllegalStateException: Unable to find a single main class from the following candidates.

Can you please let me know, if there is some thing wrong with the above configuration? 如果上述配置有问题,可以让我知道吗? I may be able to use maven profiles to create different artifacts. 我也许可以使用Maven概要文件来创建不同的工件。 However, I wanted to understand the problem with the above configuration. 但是,我想了解上述配置的问题。 Any help will be greatly appreciated. 任何帮助将不胜感激。

I think both those configurations are active at the same time (otherwise how do you tell maven which one to use?). 我认为这两个配置都同时处于活动状态(否则,您如何告诉Maven使用哪个配置?)。 You could put them both in Maven profiles. 您可以将它们都放在Maven配置文件中。

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

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