I have a project created from a template. When I do sbt run
I select a class with main and it runs. But when I pass the class with sbt "runMain com.mitzit.WordCount"
it fails. How can I pass the class with main that I want to run from the command line? I don't want to edit build.sbt
Steps to reproduce
get project:
sbt new tillrohrmann/flink-project.g8 \
--name=sbt-flink-template \
--organization=com.mitzit \
--version=0.1 \
--flink_version=1.7.0 \
--scala=2.12.11
This works
run
sbt run
Multiple main classes detected, select one to run:
[1] com.mitzit.Job
[2] com.mitzit.SocketTextStreamWordCount
[3] com.mitzit.WordCount
Enter number: 3
[success] Total time: 395 s, completed Apr 22, 2020 4:24:22 PM
This Fails
sbt "runMain com.mitzit.WordCount"
[error] Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/flink/api/common/typeinfo/TypeInformation
[error] at com.mitzit.WordCount.main(WordCount.scala)
How can I run a specific main without having to select it each time?
The issue is that in the root project part of the Flink libraries are classified as provided
To overcome this issue this template project tillrohrmann/flink-project.g8
is providing an utility sub-project mainRunner
that simply edit the dependency configuration, removing the provided
classifier to enable running it from IntelliJ (or sbt as you are asking)
you can simply run
sbt "mainRunner/runMain com.mitzit.WordCount"