Spring Boot 应用程序未更改
Posted
技术标签:
【中文标题】Spring Boot 应用程序未更改【英文标题】:Spring Boot Application not changing 【发布时间】:2019-08-07 23:22:13 【问题描述】:我以前做过一个项目。 (https://github.com/sercandorman/CRUD-Operations-With-Spring) 现在我想通过它。当我将 html 文件添加到资源/模板中时,我可以看到该页面。在那个页面中,我试图从 mysql 数据库中获取数据。同时我尝试使用相同的 ajax/get 方法,但遇到 404 no messages found 错误。而且我确信我使用了正确的 RequestMapping 和 Thymeleaf 迭代。我以前已经用过,所以我做了同样的事情,但只是来自不同的桌子。我无法理解“为什么”!? ...
然后我尝试更改之前工作的 RequestMapping 方法(findAll)。没有任何改变。方法仍然像旧方法一样运行!我试图打破它,但不,没有任何反应。怎么可能?!
注意:我尝试打开项目 Spring Tool Suite 和 Netbeans。面对无数错误后,用 STS 成功打开了项目,但看看它。我不能改变它原来的形式。
这是关于战争/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 方法时,没有任何变化,我的 /lists 方法也不起作用。
我必须做什么?
【问题讨论】:
【参考方案1】:我既不是 Netbeans 也不是 STS 专家,但要排除来自您的 IDE 的任何问题,您可以尝试以下方法:
项目的完整重建和启动,以便 Java 或资源文件中的任何更改都有机会反映在您的下一次服务器启动中:
mvn clean spring-boot:run
请确保您停止所有正在运行的服务器您之前启动的。
【讨论】:
先生,非常感谢。我希望我能先问一下。有效。我爱你 !我只是对“我不能再对我导入的项目使用任何 IDE 吗?”感到困惑。 呵呵呵呵,太爱我了,我已经结婚了。 ;-) 当然,你仍然可以使用任何你想要的 IDE,我只是想强调一下,我个人对上述两种 IDE 都没有经验,我是 IntelliJ 用户。 @SercanDorman 你可以使用任何 IDE,你应该只使用你的 IDE 的 `import maven project' 功能。以上是关于Spring Boot 应用程序未更改的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot 未使用 Spring Data 和 Hibernate 与 sql Server 一起运行
使用 Spring boot webflux reactive 记录未持久化到 R2DB
应用程序版本未显示在 Spring Boot banner.txt 中