Using Maven and Spring and Apache Spark in IntelliJ cause error

I have a Maven Spring projects that works fine without any error when I run this in terminal:

java -jar myPro.jar

But when I add spark dependency in pom.xml, this error appears:

Error: Could not find or load main class com.test.myProject.myMainClass

My pom.xml is:




xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

com.test

myProject

0.0.1-SNAPSHOT

jar



SUSAHCRUDNIE

Spring Boot Employee Application



org.springframework.boot

spring-boot-starter-parent

1.5.4.RELEASE







UTF-8

UTF-8

1.8







org.apache.spark

spark-sql_2.11

2.4.0





org.slf4j

slf4j-log4j12





log4j

log4j









org.springframework.boot

spring-boot-starter-data-jpa





org.springframework.boot

spring-boot-starter-thymeleaf





org.springframework.boot

spring-boot-starter-web





mysql

mysql-connector-java

runtime

8.0.13





org.springframework.boot

spring-boot-starter-test

test





org.webjars

bootstrap

3.3.7





org.webjars

jquery

1.12.4











org.springframework.boot

spring-boot-maven-plugin

2.1.0.RELEASE







repackage











org.apache.maven.plugins

maven-assembly-plugin

3.1.0





jar-with-dependencies







com.test.myProject.myMainClass











make-assembly

package



single











org.apache.maven.plugins

maven-jar-plugin

3.1.0





true



true

com.test.myProject.myMainClass















The dependency which is cause that error is:



org.apache.spark

spark-sql_2.11

2.4.0





org.slf4j

slf4j-log4j12





log4j

log4j







The myMainClass is:

package com.test.myProject;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.context.annotation.Configuration;

import org.springframework.context.annotation.PropertySource;

@Configuration

@SpringBootApplication

@PropertySource("application.properties")

public class myMainClass{

public static void main(String[] args) {

SpringApplication.run(myMainClass.class, args);

}

}

In stackoverflow, there are a lot of questions about not finding main class, but...

Read More »

By: StackOverFlow - Friday, 9 November

Related Posts