Spring Tool Suite finds spring-boot integration test configuration and does not start main application - spring-boot

I have a little struggle with Spring Tool Suite in combination with spring-boot.
I created a custom Maven spring-boot-web-application including several JUnit tests, one of this test is an integration test which has a configuration for the testapplication.
If I want to start the spring-boot-web-application via Spring Tool Suite ( run as -> Spring Boot Application ) the application does not start because both configurations ( src/main/java, src/test/java ) are found and conflict each other.
As soon I remove the test resources from the buildpath the application starts as expected.
Is there any setting in Spring Tool Suite to prevent the test resources are added to the classpath when starting the spring-boot-web-application?
Thank you in advance!

STS 3.6.4 has a bug in it that causes the classpath for "Run As >> Spring Boot App" on maven projects to include 'test stuff' (source folders and jar dependencies) to be on the runtime classpath.
The bug is a regression as it did not exist in 3.6.3. The bug is fixed already in master and the fix will be part of STS 3.7.0. You can get this fix today by updating your STS installation from the nightly update site:
http://dist.springframework.org/snapshot/IDE/nightly/
Open "Help >> Install New Software" and paste the above link in the "work with" field and then install the "Core" pieces. The installer will inform you that you already have these and will perform an upgrade instead.
After this upgrade is succesful, "Run As >> Boot App" should no longer have test stuff on the runtime classpath.

Related

Springboot not recognized on IntelliJ

Even after installing Java and Maven, creating a spring project from springinitializr is facing an issue. The issue is that the project is not recognised as spring project, the annotations, import nothing are working. Can anyone please help out
I tried to redo the process, but things were same. Is any settings.xml needs to be made but I don't see it as necessity.
When opening your project in intellij. you should do so via the import > new Project and choose the pom.xml for the generated project from spring initialize. This way it can resolve dependencies and properly open your project.
if the problem persists you can go to your MainApplication.java > right click > run as spring boot project.
If it does not put the configuration on the run shortcut on the up right of the application you can configure it by adding the command : mvn spring-boot:run and add other configurations id desired.

Intellij MavenWrapperDownloader.java: Can not resolve symbol error

Setup:
Intellij IDEA community edition 2020.2
Spring Bott starter parent: 2.3.5
Java 11
WRAPPER_VERSION: 0.5.6
mvn 2
Hi,
I googled a lot e.g. here but I just can't fix it.
I created a new mvn spring project with Intellij. When I commit the project I get errors detected by code analyses in class: MavenWrapperDownloader.java.
e.g. It reports:
Cannot resolve symbol String
I tried:
invalidate caches and restart
delete .idea folder and reimport
checked sdk setup
mvn reimport
mvn clean and then rebuild (while the build is always successful)
I'm pretty new to maven. I guess the scope of the mvn package might be wrong because the build process works as expected.
UPDATE:
I reinstallt my openjdk11. No success. Then I found out that my .mvn/wrapper dir is not set as source root. I know that was never the case in my other projects. As a trial I've set my .mvn folder as source root and now the MavenWrapperDownloader.java file is recognized as a java class and the compiler interprets the symbols. But now there is another error. It says I have to define a package name for that class because the class does not have one per default. It is pretty strange to me. I also tried to use another spring boot starter version but nothing changed
When I execute Analyze->inspect code I get the following:
I had the same problem and File -> Invalidate Caches/Restart fixed it - at least for now.
IntelliJ Ultimate 2020.3
Spring Boot Starter Parent 2.4.2
Java 15
Maven 4.0.0
Maven Wrapper 0.5.6
The easiest solution is to generate your project again with Spring Starter.
After you set up everything you need at pom file -> Generate -> Download it.
Open with your IDE and copy-paste all code sources which you have already written.

Hot swap available by maven wrapper (mvnw)?

I added spring boot dev tool dependency in current Spring boot application, but when running the application by mvnw spring-boot:run It seems not recognized the change made in Java
I do use Eclipse to make the code change and enable automatically build. and refresh my code. So i think the latest .class file should be under /target directory
So does mvnw supports hot swap at all?

Spring boot application as a shipable standalone jar

So I created a spring boot application. And I simply like to run it as a program from a Main class. No need for web controller access.
It runs great in my Intellij.
But how do I ship it as a jar?
It depends on your project structure. If you use maven just run "maven install" and find your jar in your local repository.
When you have it, run "java -jar your.jar"

Spring Tool Suite (STS) not downloading Maven Dependencies automatically after starting Spring Starter Project in Mavericks

Our Spring Tool Suite (STS) not downloading Maven Dependencies automatically after starting Spring Starter Project with Web Style.
We are using:
Spring Tool Suite
Version: 3.6.1.RELEASE
Build Id: 201408250818
Platform: Eclipse Luna (4.4)
Maven 3.2.3
This issue is only happening on a computer running Mavericks. Other computers running Mountain Lion seems to run fine.
We have already tried Update the Project, Refreshing, Rebooting, Re-opening STS, opening Preferences >> Maven >> Checking Download repository index updates on startup and Update Maven projects on Startup.
All without success. Anyone having the same issue? Thanks.

Resources