Spring Boot-Controller 404

Ich bin ziemlich neu in Spring Boot und versuchen, erstellen Sie eine einfache web-app. Ich habe eine controller-Klasse mit meinem mapping für den url, aber auf browser-es ist mir eine white-label-Seite-Fehler(404). Ich bin nicht in der Lage zu verstehen, warum es nicht in der Lage, um die Karte. Ich habe versucht, meine component-scan base-package, aber es immer noch nicht umleiten mich auf die Seite "abc" oder " drucken "im controller" in der Konsole.

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>bms</groupId>
    <artifactId>com.wellmanage.bms</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>BMS</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

Controller-Klasse

package com.wellmanage.controller;   

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BookController {

    @RequestMapping("/")
    public String hello() {
        System.out.println("in controller");
        return "abc";
    }
}

Main-Klasse

package com.wellmanage.bms;

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

@SpringBootApplication
public class BmsApplication {

    public static void main(String[] args) {
        SpringApplication.run(BmsApplication.class, args);
    }
}
name der Seite ist "abc" nicht Hallo.Sorry für die Tippfehler.
Stellen Sie sicher, dass Sie mit @RestController nicht @Controller.

InformationsquelleAutor Gaurav Bipul | 2016-05-20

Schreibe einen Kommentar