spring应用程序以错误的页面开始

rjzwgtxy  于 2021-06-29  发布在  Java
关注(0)|答案(1)|浏览(343)

白天好!
我的应用程序在开始时显示另一个项目(甚至没有打开)的页面。在google之后,我已经清理了浏览器并在application.properties中设置了另一个服务器端口。尝试了不同的浏览器。什么都没变。
服务器没有错误。

我是波姆。

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.12.RELEASE</version>
        <relativePath/> <!-- lookup parent from repositories -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>spring-security-jpa</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>spring-security-jpa</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>

        <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.12</version>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <version>2.3.4.RELEASE</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
            <version>2.3.4.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
    </dependencies>

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

</project>

这是佩奇。

<!DOCTYPE html>
    <html lang="en" xmlns:th="http://thymeleaf.org">
    <head>
        <meta charset="ISO-8859-1">
        <title>Registration</title>
        <link rel="stylesheet"
              href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
              integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
              crossorigin="anonymous">
    </head>
    <body>

    <!-- create navigation bar ( header) -->
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed"
                        data-toggle="collapse" data-target="#navbar" aria-expanded="false"
                        aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span> <span
                        class="icon-bar"></span> <span class="icon-bar"></span> <span
                        class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#" th:href="@{/}">Registration and
                    Login Module</a>
            </div>
        </div>
    </nav>

    <br>
    <br>
    <!-- Create HTML registration form -->
    <div class="container">
        <div class="row">
            <div class="col-md-6 col-md-offset-3">

                <!-- success message -->
                <div th:if="${param.success}">
                    <div class="alert alert-info">You've successfully registered!</div>
                </div>

                <h1>Registration</h1>

                <form th:action="@{/registration}" method="post" th:object="${user}">
                    <div class="form-group">
                        <label class="control-label" for="firstName"> First Name </label>
                        <input id="firstName" class="form-control" th:field="*{firstName}"
                               required autofocus="autofocus" />
                    </div>

                    <div class="form-group">
                        <label class="control-label" for="lastName"> Last Name </label> <input
                            id="lastName" class="form-control" th:field="*{lastName}"
                            required autofocus="autofocus" />
                    </div>

                    <div class="form-group">
                        <label class="control-label" for="email"> Email </label> <input
                            id="email" class="form-control" th:field="*{email}" required
                            autofocus="autofocus" />
                    </div>

                    <div class="form-group">
                        <label class="control-label" for="password"> Password </label> <input
                            id="password" class="form-control" type="password"
                            th:field="*{password}" required autofocus="autofocus" />
                    </div>

                    <div class="form-group">
                        <button type="submit" class="btn btn-success">Register</button>
                        <span>Already registered? <a href="/" th:href="@{/login}">Login
                                    here</a></span>
                    </div>
                </form>
            </div>
        </div>
    </div>
    </body>
    <head/>

请帮忙。

b5lpy0ml

b5lpy0ml1#

尝试向pom.xml中添加以下代码:

<start-class>com.example.springsecurityjpa.SpringSecurityJpaApplication</start-class>

还有,你不应该 SpringSecurityJpaApplication 在所有仓库之外,在 com.example.springsecurityjpa 而不是 com.example.springsecurityjpa.services 包裹?

相关问题