简体   繁体   中英

Spring framework boot does not exist?

I am running the following application:

package com.h2o;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class H2oRestServiceApplication {

    public static void main(String[] args) {
       SpringApplication.run(H2oRestServiceApplication.class, args);
   }
}

My pom.xml file can be found here: https://github.com/shilpakancharla/ReutersSearchEngine/blob/master/h2o/pom.xml

I am getting the following errors when trying to run javac

H2oRestServiceApplication.java from my terminal: 

H2oRestServiceApplication.java:3: error: package org.springframework.boot does not exist
import org.springframework.boot.SpringApplication;
                               ^
H2oRestServiceApplication.java:4: error: package org.springframework.boot.autoconfigure does not exist
import org.springframework.boot.autoconfigure.SpringBootApplication;
                                             ^
H2oRestServiceApplication.java:6: error: cannot find symbol
@SpringBootApplication
 ^
  symbol: class SpringBootApplication
H2oRestServiceApplication.java:10: error: cannot find symbol
        SpringApplication.run(H2oRestServiceApplication.class, args);
        ^
  symbol:   variable SpringApplication
  location: class H2oRestServiceApplication
4 errors

Could someone explain if there is something wrong with my pom.xml? I am not sure how to fix this or what dependencies I am missing.

I have done the below steps and your application is up and running -- I was able to view the swagger UI as well.

1) Cloned your repository

git clone https://github.com/shilpakancharla/ReutersSearchEngine.git

2) Switched to your project directory

cd ReutersSearchEngine/h2o

3) Did a Maven Clean Package (as your's is a maven based spring boot project)

mvn clean package

Waited for maven to download dependencies, compile sources and build an executable jar.

It created a jar with name h2o-0.0.1-SNAPSHOT.jar inside target directory.

4) Simply launched the jar file using the below command.

java -jar target/h2o-0.0.1-SNAPSHOT.jar

The application started fine with these logs at the end.

2018-11-19 16:56:01.928  INFO 7288 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 80 (http) with context path ''
2018-11-19 16:56:01.932  INFO 7288 --- [           main] com.h2o.H2oRestServiceApplication        : Started H2oRestServiceApplication in 8.595 seconds (JVM running for 9.116)

5) As the application started on port 80 , I visited the below address on my browser.

http://localhost/swagger-ui.html

And your swagger-ui showed up as below.

在此处输入图片说明

Hope this helps!

If you still face issues, please post it here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM