2

I have created a spring boot application which is working fine but I am not able to get rest service which is clubbed with that application. Please find below code. I am able to access url http://localhost:8080/springbootr/ but not able to access web-service url http://localhost:8080/springbootr/Hello/, getting 404 at the moment of web service calling.

@Configuration
@ComponentScan(basePackages={"controller"})

@SpringBootApplication
public class Application {
    public static void main(String[] args) throws Exception {
         SpringApplication.run(new Object[] { Application.class }, args);
    }
}

@RestController
public class UserController {

    @RequestMapping(value ="/Hello/", method = RequestMethod.GET)
    public String greeting() {
        System.out.println("Achyut");
        return "HEllo";
    }
}

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.yash</groupId>
  <artifactId>springbootr</artifactId>
  <version>0.0.1-SNAPSHOT</version>


  <name>spring-resource</name>
  <description>spring-resource</description>
  <packaging>war</packaging>
  <properties>
     <java.version>1.7</java.version>
  </properties>

  <parent>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-parent</artifactId>
       <version>1.2.3.RELEASE</version>
  </parent>
  <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
  </dependencies>
</project>

I am new to this application, please help me out.

4
  • You may try a slightly different URL: http://localhost:8080/Hello/. Commented Jan 15, 2016 at 12:00
  • is your ` System.out.println("Achyut");` getting executed? Commented Jan 15, 2016 at 13:18
  • hi, thanks for your explanation but facing same issue still, am not able to hit main user controller. i have written SOP on main controller and hit of web service that should print out put on console which is not happening, i guess some configuration required or some annotation needed which i missed. could you please guide me on same.. Commented Jan 18, 2016 at 5:53
  • no, SOP is not executing. Commented Jan 18, 2016 at 5:55

2 Answers 2

1

You may try a slightly different URL: http://localhost:8080/Hello/. You can also take a look at option spring.data.rest.base-path.

If you fail to make it work, then let start from a working sample app like spring-boot-sample-data-rest available on the GitHub.

Sign up to request clarification or add additional context in comments.

2 Comments

hi, thanks for your explanation but facing same issue still, am not able to hit main user controller. i have written SOP on main controller and hit of web service that should print out put on console which is not happening, i guess some configuration required or some annotation needed which i missed. could you please guide me on same.
@user1201734 then I'm afraid I can't help. As you have problems with configuring a new app, you may consider starting from a working sample application I mentioned above. It can save your time.
0

Firstly u should try different paths http://localhost:8080/Hello/ Secondly I experienced like this issue, my solution is changing (package or param) paths because some versions dont know some params, if u will change in the xml part, It will running(sorry for my language :) )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.