I have a Spring Boot application in which I renamed package where starting class is in. Application runs without any problem when launching from IDE (Spring Tools Suite) but when I build it with maven and run from command line with
java -jar <application_name.jar>
It says that class in old_package cannot be found. Things I've tried so far:
Clean project
Delete metadata from workspace
Copy project somewhere else and import it from there
Deleting Run Configuration and creating new one with main class in new package.
I also unzipped jar located in target folder and checked its manifest file and Start-Class param is set to old package.
You didn't update your pom.xml
, and it contains references written in the form <old_package>.MyClass
, whereas this should be <new_package>.MyClass
. Your IDE (I'm not an expert with STS though) uses its own rules for compilation, so your program can run in it.