I got a project from GitHub which is a Java spring boot application running with Maven dependencies. I am so confused why I can't run the application successfully on STS. There's no longer a problem on my old laptop. Because I just changed my laptop, this problem only occurred on this laptop.
The details / symptoms of the issue are:
- When I typed "SpringToolSuite" on my start panel, no applications were being recognized. So I have to open STS manually from Downloads (ie. its original file location). But anyways, it is just a minor issue.
- In STS, annotations such as the lombok log and most of the getter/setter methods were unrecognized.
- Failed to perform "Run as Spring Boot App" from STS, but it is successful when I tried to perform "mvn clean install" to create a Maven build from command prompt.
- Error message: "log cannot be resolved"
I tried finding results from other posts here but to no avail.
The steps that I import the project is:
- Create another folder as the workspace.
- Open STS by selecting the created folder as the workspace.
- Click File > Import and import as existing Maven project (as it is a Maven-built application).
I also tried to create a Maven build from command prompt, which is successful eventually.
As the situation was so strange here, please advise further what I can do. Thanks.
CodePudding user response:
There are several potential causes of the issues you are experiencing. Here are some possible solutions you can try:
- Make sure you are using the latest version of STS. Older versions may not be compatible with newer versions of Java or with newer Maven dependencies.
- Make sure you have the required dependencies installed on your machine. The error message "log cannot be resolved" suggests that the lombok library, which provides the @Log annotation, is not available on your classpath. You can check the project's pom.xml file to see if lombok is listed as a dependency, and if so, try running mvn clean install from the command prompt to ensure that all dependencies are installed.
- Try running mvn clean install from the command prompt and see if the build is successful. If it is, then the issue may be with STS itself. You can try reinstalling STS or switching to a different IDE, such as IntelliJ IDEA.
- If the build is not successful, check the error messages to see what the specific issues are. There may be missing dependencies or other issues that need to be resolved before the project can be built and run.
CodePudding user response:
Thanks so much for your suggestions.
First of all, I've made sure my STS the latest version. I installed it from the official site https://spring.io/tools. I downloaded the Windows one. See image. I executed the spring-tool-suite-4-4.16.1.RELEASE-e4.25.0-win32.win32.x86_64.self-extracting.jar file afterwards. A folder with STS application inside has been generated.
Referring to your second question, I am sure I have the lombok dependency. This is part of my pom.xml. See image. I also performed again the "mvn clean install". It is success and error-free.
Fyi, I also make sure every setup is right, such as:
- It is pointing to the same java version as what Maven points to.
- In STS, the Java compliance level is the same as the java version I defined in PATH environment variable.
- Also in STS, the Installed JRE is pointing to the right folder.
But as the STS is still not recognizing Spring Boot annotations. That's why it seems weird here. For example, logs are underlined red with an error message on the IDE. Getters and Setters of @Data fields are not implicitly referenced with that spring boot annotation since they're also underlined with error.