Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

924
Views
SpringBoot: no se puede encontrar una sola clase principal de los siguientes candidatos

Generé una aplicación web Spring Boot utilizando Spring Initializer, Embedded Tomcat, Thymeleaf template Engine. Tecnologías utilizadas: Spring Boot 1.4.2.RELEASE, Spring 4.3.4.RELEASE, Thymeleaf 2.1.5.RELEASE, Tomcat Embed 8.5.6 , Experto 3, Java 8

Tengo una aplicación SpringBoot. con estas 2 clases:

 @Profile("!war") @SpringBootApplication @Import({SecurityConfig.class ,PersistenceConfig.class, ServiceConfig.class}) public class BookApplication { public static void main(String[] args) { SpringApplication.run(BookApplication.class, args); } } @Profile("war") @Import({SecurityConfig.class ,PersistenceConfig.class}) @SpringBootApplication public class BookApplicationWar extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(BookApplicationWar.class); } public static void main(String[] args) throws Exception { SpringApplication.run(BookApplicationWar.class, args); } }

Genero la guerra con este comando

 mvn clean package -DskipTests -Dspring.profiles.active=pebloc,war -DAPP-KEY=pebloc

Pero tengo este error:

 [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.2.RELEASE:repackage (default) on project book: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.2.RELEASE:repackage failed: Unable to find a single main class from the following candidates [com.tdk.BookApplication, com.tdk.BookApplicationWar] -> [Help 1]
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Si tiene más de una clase principal, debe configurar explícitamente la clase principal en cada perfil:

 <profiles> <profile> <id>profile1</id> <properties> <spring.boot.mainclass>com.SomeClass</spring.boot.mainclass> </properties> </profile> <profile> <id>profile2</id> <properties> <spring.boot.mainclass>com.SomeOtherClass</spring.boot.mainclass> </properties> </profile> </profiles>

...

 <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.5.2.RELEASE</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> <configuration> <mainClass>${spring.boot.mainclass}</mainClass> </configuration> </execution> </executions> ... </plugin>

Ver spring-boot: reempaquetar

over 4 years ago · Santiago Trujillo Report

0

Defina una sola clase principal a través de la propiedad de clase de inicio

 <properties> <start-class>com.may.Application</start-class> </properties>

Alternativamente, defina la clase principal en el complemento spring-boot-maven

 <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.may.Application</mainClass> </configuration> </plugin> </plugins> </build>

O a través de perfiles

 <profiles> <profile> <id>profile1</id> <properties> <spring.boot.mainclass>com.may.Application1</spring.boot.mainclass> </properties> </profile> <profile> <id>profile2</id> <properties> <spring.boot.mainclass>com.may.Application2</spring.boot.mainclass> </properties> </profile> </profiles> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> <configuration> <mainClass>${spring.boot.mainclass}</mainClass> </configuration> </execution> </executions> </plugin> </plugins> </build>
over 4 years ago · Santiago Trujillo Report

0

A veces se da este error cuando haces mvn install sin hacer mvn clean.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!