Spring Boot Maven project giving error after importing on STS-4 - spring-boot

I have the IDE Spring Tool Suite 4 and I imported the Spring Boot project generated by JHipster using the option "Import > Existing Maven project", however, the project show error in the first line which is just a comment in package-info.java and because of that the project not run when I try initialize by Boot Dashboard in IDE.
The IDE show this erros:
The project was not built since its build path is incomplete. Cannot find the class file for javax.servlet.ServletException. Fix the build path then try building this project;
The type javax.servlet.ServletException cannot be resolved. It is indirectly referenced from required .class files
I tried:
project > clean;
right click in project > Run > Maven clean;
right click in project > Maven > Update project;
Usually this steps work, but not in this project.
When i open the terminal and write mvn clean package and run the .war or execute ./mvnw the API works.
Why does this error occur in STS 4 if the terminal compiles without problems?

Related

Why rebuild of Kotlin application removes target class files in Eclipse?

I'm trying to setup an app written in Kotlin, built on Maven and using Spring Boot in Eclipse.
I manage to run the application only if I do Maven build of the project which generates class files in target/classes dir. If I do clean the project then Eclipse rebuilds it automatically and removes all class files from target/classes dir.
I think that re-build of the project should re-compile class files in target/classes directory, not just to remove them. Otherwise it means that I need to re-build project as Maven on each code change which I seems to be a wrong way to go.
Please point me the correct way to setup a Kotlin - Maven - Spring Boot project in Eclipse.
My setup is:
Eclipse is 4.26.0.
Maven EMBEDDED 3.8.6.
Kotlin Plugin for Eclipse 0.8.24 (it causes intallation of Enhanced Kotlin for Eclipse plugin).
Spring Tools 4 - 4.17.2.RELEASE.
OpenJDK 11.0.2.
What I did:
Installed all the above (Eclipse, plugins, JDK and etc).
Imported the project as a Maven project in Eclipse: github link.
Import dialog
Right click on DemoApplication.kt -> Run As -> 1 Kotlin Application. I got an error:
Error: Could not find or load main class com.example.demo.DemoApplicationKt
Caused by: java.lang.ClassNotFoundException: com.example.demo.DemoApplicationKt
Right click on pom.xml -> Run As -> 2 Maven build...
Goals: clean install -> Run.
After that I see in {project dir}\target\classes\com\example\demo class files were generated.
If then I do right click on DemoApplication.kt -> Run As -> 1 Kotlin Application it runs OK.
If I click on Project -> Clean... (with Build Automatically ON) - all files from {project dir}\target\classes\com\example\demo got removed and I again start at point 3.
I tried couple configuration options, but they didn't help:
Making Window -> Preferences -> Java -> Compiler -> Building -> Output folder -> Scrub output folders when cleaning projects OFF doesn't help - class files still got removed.
In Package Explorer -> Kotlin Runtime Library there is a virtual directory kotlin_bin which has all class files. I tried to setup it as Dependencies:
Run Configuration dependencies setup
But it fails to run then with the below error:
Error when run it

Maven doesn't recognize dependencies added in IntelliJ project structure

I need to use external dependencies for tomcat. I add them to project structures and project build fine. Compiler doesn't show any errors
project structure
The project works fine when i run it on IDE.
The problem starts when I try to build WAR file using Maven package :
package org.apache.catalina does not exist
package org.apache.catalina.connector does not exist
package org.apache.coyote does not exist
I've try with all different scope settings but jars aren't found

How do I run the Spring RESTful Web Service

I've installed the spring example RESTful Web Service. And I have it building fine in IntelliJ. But how do I get IntelliJ to create gs-rest-service-0.1.0.jar? There are menu commands to synchronize gradle & maven, but nothing to use them to build the jar.
A standard POM/Maven-based project can be built via the console by typing:
mvn package
the maven lifecycle, by default, will place the output artifact (i.e. JAR / WAR file) under the target folder.
Alternatively, since you are using IntelliJ, you can also use the IDE to run the build for you. The simplest way is to navigate on the right side tab
mvn > your_project > lifecycles > package
the output will continue to be placed in the same target folder.
Assuming the project has a pom file. And it was mentioned building fine in the post. Assumption: STS/Eclipse users
Right click on pom file -> run as maven build. In the console it displays where the jar file is created.
Go to: project folder -> target folder -> gs-rest-service-0.1.0.jar
file

Spring STS MVC Project - Unable to Get Rid of Error

I have the newest STS build and have installed on Window 8.1. Following tutorials, I get a pom.xml error. Following any and all suggestions, including re-installing the STS does not fix it.
it is a maven configuration problem, try :
Right click on the project > run > maven build ...> goal : eclipse:clean
and then update the project
if the error is not fixed , then may be you have some corrupted dependencies
delete the folder .m2 under C:\Users\<the current user>\.m2 and update the project again, maven will load the missing jars again.

MyEclipse 8.5 creating 'maven-archetype-quickstart' has encountered a prob?

I use the built-in maven of MyEclipse 8.5 to create maven projects.
It shows the following error:
Image is here:pic
Sorry, because I'm new I can't post pictures here yet.
I did it twice on two computers (both are MyEclipse 8.5), but the error was the same.
I use a Eclipse to do the same job and it is successful.
But when using MyEclipse 8.5 to do the job if check "create a simple project (skip archetype selection)" during the process, the project can be created and no error happens, but there is no the folder "Maven Dependencies" in the project created in Package Explorer.
Is this a bug of this version of MyEclipse? Because Eclipse Indigo works fine on this.
If you create a simple project, the folder Maven Dependencies is missing simply because there are no Maven Dependencies in a simple project. Just add a dependency, and the folder Maven Dependencies should be created with your dependency in it.

Resources