我是Spring靴的初学者。我制作了简单的crud应用程序,但在编译项目时没有任何错误,但在浏览器中看不到输出。我不知道为什么。
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
只有这样显示才能在浏览器中看到输出。我不知道为什么。
员工控制员看起来像这样
@Controller
public class employeeController {
@Autowired
private employeeservice service;
@RequestMapping("/")
public String viewHomePage(Model model) {
List<employee> listemployee = service.listAll();
model.addAttribute("listemployee", listemployee);
return "index";
}
@RequestMapping("/new")
public String showNewEmployeePage(Model model) {
employee emp = new employee();
model.addAttribute("employee", emp);
return "new_employee";
}
Index.html
<tbody>
<tr th:each="employee : ${listemployee}">
<td th:text="${employee.id}">Employee ID</td>
<td th:text="${employee.firstname}">FirstName</td>
<td th:text="${employee.brand}">LastName</td>
<td>
<a th:href="@{'/edit/' + ${employee.id}}">Edit</a>
<a th:href="@{'/delete/' + ${employee.id}}">Delete</a>
</td>
</tr>
</tbody>
2020-09-18 13:05:15.081 INFO 10660 --- [ main] com.example.gov.GovApplication : Starting GovApplication on kobinath-pc with PID 10660 (C:\Users\kobinath\eclipse-workspace1s\gov.zip_expanded\gov\target\classes started by kobinath in C:\Users\kobinath\eclipse-workspace1s\gov.zip_expanded\gov)
2020-09-18 13:05:15.085 INFO 10660 --- [ main] com.example.gov.GovApplication : No active profile set, falling back to default profiles: default
2020-09-18 13:05:15.993 INFO 10660 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-09-18 13:05:16.082 INFO 10660 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 73ms. Found 1 JPA repository interfaces.
2020-09-18 13:05:17.018 INFO 10660 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9040 (http)
2020-09-18 13:05:17.031 INFO 10660 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-09-18 13:05:17.031 INFO 10660 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.38]
2020-09-18 13:05:17.184 INFO 10660 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-09-18 13:05:17.184 INFO 10660 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2015 ms
2020-09-18 13:05:17.468 INFO 10660 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-09-18 13:05:17.532 INFO 10660 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-09-18 13:05:17.643 INFO 10660 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.21.Final
2020-09-18 13:05:18.072 INFO 10660 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-09-18 13:05:18.094 INFO 10660 --- [ main] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page template: index
2020-09-18 13:05:18.301 INFO 10660 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-09-18 13:05:18.410 INFO 10660 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9040 (http) with context path ''
2020-09-18 13:05:18.412 INFO 10660 --- [ main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2020-09-18 13:05:18.615 INFO 10660 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-09-18 13:05:18.657 INFO 10660 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL55Dialect
2020-09-18 13:05:19.546 INFO 10660 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-09-18 13:05:19.558 INFO 10660 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-09-18 13:05:19.836 INFO 10660 --- [ main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2020-09-18 13:05:19.849 INFO 10660 --- [ main] com.example.gov.GovApplication : Started GovApplication in 5.297 seconds (JVM running for 5.845)
porm.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 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.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>gov</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>gov</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
spring.jpa.hibernate.ddl-car=无
spring.datasource.url=jdbc:mysql://localhost:3306/gov?useUnicode=true
server.port=8030
spring.datasource.username=root
spring.datasource.password=
logging.level.root=WARN
spring.jpa.open-in-view=false
我相信你在Enity和模板之间犯了一些错别字。我希望这个回购能帮上忙
https://github.com/toannh0104/spring-boot-test
我更喜欢按照java标准编写代码,这样可读性更强
https://imgur.com/wrTWBp9
https://imgur.com/ct7k2uI
https://imgur.com/iw5bS0c
仅当应用程序关闭时,数据有效负载的使用不会收到任何通知,并且不会触发消息接收方法。 在下图中显示数据负载,单击此处查看参数 回复是点击这里查看回复 响应成功1,但在redmi手机中未收到任何通知。
我们的用户一直在报告我们的渐进式Web应用程序没有出现在他们的应用程序抽屉里。我在运行谷歌Chrome65的三星Galaxy S5和S6上复制了这一点。我使用菜单“添加到主屏幕”,图标显示在主屏幕上,但不显示在“应用程序”抽屉或应用程序管理器设置屏幕。 这表明我的PWA没有得到“webapk”(也就是“改进后添加到主屏幕”)的治疗,但我不知道为什么。根据谷歌的链接,改进后的A2HS在Chrome
我已经为我的spring boot应用程序配置了测微计和prometheus,我可以在endpoint/执行器/prometheus处看到以下指标(使用计时器生成): 但当我在Grafana中运行其中一个查询(针对prometheus实例配置)时,我没有看到任何结果。 这需要任何配置吗?
在我的项目中,我想使用特定于环境的属性文件。例如,如果我在开发中运行它,它应该使用应用程序。dev.properties,对于生产,它应该使用应用程序。产品属性等等。 我有下面两个文件在我的资源文件夹。 application.properties(用于生产) application.dev.properties(用于开发) 我有一个属性像下面的每个文件。 为了刺激 给德夫 我有一门课,如下所示
我有一个应用程序,它可以完全打开,但我在为它设置图标时遇到了麻烦。我给出路径的图标就在那里,在该目录中切换到另一个imagine会显示图标9/10次,但这张图片从未显示。在它的位置上总是有一个问号。所以,即使在另一个文件上,我知道它会工作(即没有损坏),为什么它很少显示? 下面是MyApplication的代码。JAVA 以下是 /img/Main.java的项目目录结构: 我在这里尝试了所有的解
我尝试在Windows Phone应用程序中创建一个列表框。我试图为它创建一个自定义datatemplate。在许多示例中,我看到了类似于这个简单的列表框: 谢了!