user2812866
user2812866

Reputation: 589

Could not run simple spring boot application() generated by STS tool

I am new to Java and SPRING, Have latest STS tool and JAVA 1.6, Able to create and run Spring MVC project.

Started looking in to spring boot, created a spring starter project Selected 'web' and picked everything default

Had multiple error in Application.Java file(See below) Fixed by adding JRE in build path. Try to run it getting Run time exception (See below).

Question : Why IDE was not able add JRE in build path for spring boot? Why I still can't run this application. Am I missing some configuration because of which IDE is not generating correct project.

Help is appreciated.

Thanks

*************** Error in Application.java Multiple markers at this line - The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files - The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files - The type java.lang.Class cannot be resolved. It is indirectly referenced from required .class files

Multiple markers at this line - Occurrence of 'Application' - Implicit super constructor Object() is undefined for default constructor. Must define an explicit


******** Run time exception***********************

Exception in thread "main" java.lang.NoClassDefFoundError: demo/Application
Caused by: java.lang.ClassNotFoundException: demo.Application

Caused by: java.lang.ClassNotFoundException: demo.Application
at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 47)

Upvotes: 1

Views: 3494

Answers (3)

Handiono
Handiono

Reputation: 1

I got same issue, fix by create new spring project, java1.7, group=> com.xxx, and artifact id=> package

Upvotes: 0

EdTheDataEngineer
EdTheDataEngineer

Reputation: 11

You need to update the start class in the pom.xml file.

In pom.xml look for the below section and update the correct location of the start-class with the correct package.

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <start-class>com.DemoApplication</start-class>
    <java.version>1.7</java.version>
</properties>

Upvotes: 1

Ninja
Ninja

Reputation: 2568

I followed this REST-guide with no error. Can you give more code in Applicaion.Java ?

OR Follow the correct guide ,spring REST code in github.The 'init' folder is a empty maven(/gradle) project. After your coding .your code is like the 'complete' folder .

Upvotes: 0

Related Questions