Spring Boot应用程序没有变化

问题描述 投票:1回答:1

我之前做过一个项目。 (https://github.com/sercandorman/CRUD-Operations-With-Spring)现在我想通过它。当我将html文件添加到资源/模板中时,我可以看到该页面。在那个页面中我试图从mysql数据库中获取数据。同时我尝试使用相同的ajax / get方法,但遇到404没有发现消息错误。而且我确信我使用了正确的RequestMapping和Thymeleaf迭代。我之前已经习惯了,所以我做了同样的事情,但只是来自不同的桌子。我无法理解'为什么'!? ...

然后我尝试更改之前正在运行的RequestMapping方法(findAll)。并没有改变。方法仍旧运行方式!我试图打破它,但不,没有任何反应。怎么可能?!

注意:我试图打开Spring Tool Suite和Netbeans项目。面对成千上万的错误后,用STS成功打开项目但看看它。我不能改变它的原始形式。

这是关于war / jar文件的吗?!我该怎么办 ?

findAll方法(工作)

@RequestMapping(value = "/findAll", method = RequestMethod.GET)
public void findAll() {
    mavIndex.addObject("allRecords", personService.findAll());
    mavIndex.addObject("mod", "VIEW_RECORDS");
}

有了这个 ;

<div class="row" id="getResultDiv" th:switch="${mod}">
...
    <div th:case="VIEW_RECORDS">
...
        <tbody>
            <tr th:each="result : ${allRecords}">
                <td th:text="${result.id}" id="tid"></td>
                <td th:text="${result.name}" id="tname"></td>
                <td th:text="${result.surname}" id="tsurname"></td>
            </tr>
        </tbody>
     </div>
</div>

但是当我这样做的时候;

 @RequestMapping(value = "/lists", method = RequestMethod.GET)
    public void findAllLists() {
    mavIndex2.addObject("allLists", listsService.findAllLists());
    mavIndex2.addObject("mod2", "VIEW_LISTS");
}

有了这个 ;

...
<tbody>
    <tr th:each="res : ${allLists}">
        <td th:text="${res.listname}"></td>
    </tr>
</tbody>

此外,我确信服务和存储库是相同的。

正如我上面提到的,当我更改/ findAll方法没有任何改变,我的/列表方法无法正常工作。

我必须做什么 ?

ajax maven spring-boot spring-mvc spring-tool-suite
1个回答
0
投票

我既不是Netbeans也不是STS专家,但要排除来自IDE的任何问题,您可以尝试以下方法:

完整的重建和项目启动,以便Java或资源文件中的任何更改都有可能反映在您的下一个服务器启动中:

mvn clean spring-boot:run

请确保停止之前启动的所有正在运行的服务器。

© www.soinside.com 2019 - 2024. All rights reserved.