I know you suggest me to use the IDEs instead, as Eclipse, IntelliJ and NetBeans, but I would like to stick with Visual Studio Code. These IDEs do not have an attractive interface I want, to improve my vision. It is my particular taste.
I am an user of macOS and I am developing a Java web app with Spring framework, because my professor demanded us to do a webservers homework for the next week. I am facing the problems of Java in Visual Studio Code.
I followed the half tutorial of Build Java Web Apps with VS Code and in the middle, it failed to compile because it didn't find org.springframework.context.* dependency or library. I have already added a dependency or library classpath to the build.gradle , but it still didn't find it.
The error:
Error: Unable to initialize main class hello.Application
Caused by: java.lang.NoClassDefFoundError: ApplicationContext
Please, check my GistGithub with four files (Application.java , build.gradle , launch.json and pom.xml :
I understand your preference to use VSCode however regarding Java I would highly recommend you to use one of the Java IDEs. The Java Debugger/Plugins for VSCode (both from Microsoft and Red hat) are preview versions and it is very possible that there are issues espacially on a complex project with spring and maven involved and it is quite likly that there is nothing wrong with your code.
I use IntelliJ for the Java stuff but unfortunately spring not available in the community edition so whether you have a ultimate license from your university or the 30 day trail is enough or you have to use one of the other to IDEs.
Stephen Florentino
Full StackOverflow Developer
I would remove this line from build.gradle
classpath("org.springframework.context:spring-boot-gradle-plugin:1.5.6.RELEASE")