Reputation: 9
I'm having issues when I run my application as a java application. I've tried various solutions but with no success. I still get the following message:
Could not find or load main class com.alliacom.audit.AuditApplication
This is the pom.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.alliacom</groupId>
<artifactId>audit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>audit</name>
<description>Alliacom auditing tool</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<repositories>
<repository>
<id>lightadmin-nexus-releases</id>
<url>http://lightadmin.org/nexus/content/repositories/releases</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.alliacom.audit.AuditApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
and this is my main application,
AuditApplication.java
package com.alliacom.audit;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
@SpringBootApplication
@EnableJpaAuditing
public class AuditApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(AuditApplication.class, args);
}
}
The project seems fine, there are no errors during build, but I don't see the cause of the problem.
Upvotes: 0
Views: 8125
Reputation: 760
You need to use the plugin like this
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.1.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
Upvotes: 0
Reputation: 50203
The fastest solution, since your pom is very small:
Got to Spring Initializer: https://start.spring.io/
Generate a new Maven / Java / SpringBoot 2.0 project.
run it and check your system is fine
start adding your customizations one at a time, and try after each modification.
In few minutes you'll have found the culprit.
Upvotes: 1
Reputation: 38300
Try removing the following from your pom file (it is not needed):
<configuration>
<mainClass>com.alliacom.audit.AuditApplication</mainClass>
</configuration>
Upvotes: 0