Spring Boot Hello World(Thymeleaf)示例(十二)

完整的Spring-boot前后台入门程序 package com.jandmin; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * springBoot 启动类 * @author JandMin * */ @SpringBootApplication public class Application { public static 阅读详情

这篇博文主要用于新手学习Spring Boot,同时也记录自己学习的过程…
文章内容主要来源于易百教程

这是一个Spring Boot Web应用示例,使用嵌入式Tomcat + Thymeleaf模板引擎,并将其作为可执行JAR文件。
使用的相关技术:

  • Spring Boot 1.4.2.RELEASE
  • Spring 4.3.4.RELEASE
  • Thymeleaf 2.1.5.RELEASE
  • Tomcat Embed 8.5.6
  • Maven 3
  • Java 8



1. 项目目录


手动创建以下文件夹目录结构:
这里写图片描述


2. 项目依赖


声明 spring-boot-starter-thymeleaf以获得开发Spring + Thymeleaf Web应用程序所需的任何程序类库。
参考如下 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>

    <artifactId>web-thymeleaf</artifactId>
    <packaging>jar</packaging>
    <name>Spring Boot Web Thymeleaf 示例</name>
    <description>Spring Boot Web Thymeleaf 示例描述</description>
    <url>http://www.yiibai.com</url>
    <version>1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.2.RELEASE</version>
    </parent>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

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

        <!-- hot swapping, disable cache for template, enable live reload -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- Optional, for bootstrap -->
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>3.3.7</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <!-- Package as an executable jar/war -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

显示项目依赖关系:

提示:spring-boot-devtools
这个spring-boot-devtools有助于禁用缓存并启用热插拔,以便开发人员总是看到最后的更改。有利于发展。阅读这篇-Spring Boot –开发工具。尝试修改Thymeleaf模板或属性文件,刷新浏览器以查看更改立即生效。



3. Spring Boot


使用@SpringBootApplication进行注释。运行此类来启动Spring Boot Web应用程序。
SpringBootWebApplication.java

package com.th;

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


@SpringBootApplication
public class SpringBootWebApplication{

    public static void main(String[] args) {
        SpringApplication.run(SpringBootWebApplication.class, args);
    }
}

一个简单的Spring控制器类:WelcomeController.java代码如下-

package com.th;

import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class WelcomeController {

    @Value("${welcome.message:test}")
    private String message = "Hello World";

    @RequestMapping("/")
    public String welcome(Map<String, Object> model) {
        model.put("message", this.message);
        return "welcom";
    }
}



4. Thymeleaf +资源+静态文件


对于Thymeleaf模板文件,放入 src/main/resources/templates/ 目录下, src/main/resources/templates/welcome.html 文件代码如下 -

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Spring Boot Thymeleaf Hello World示例</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<link rel="stylesheet" type="text/css"
    href="webjars/bootstrap/3.3.7/css/bootstrap.min.css" />

<link rel="stylesheet" th:href="@{/css/main.css}"
    href="../../css/main.css" />

</head>
<body>

    <nav class="navbar navbar-inverse">
        <div class="container">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">Spring Boot</a>
            </div>
            <div id="navbar" class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#">首页</a></li>
                    <li><a href="#about">关于</a></li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container">

        <div class="starter-template">
            <h1>Spring Boot Web Thymeleaf示例</h1>
            <h2>
                <span th:text="'Message: ' + ${message}"></span>
            </h2>
        </div>

    </div>
    <!-- /.container -->

    <script type="text/javascript" src="webjars/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>

对于静态文件,如CSS或Javascript,将它们放入 /src/main/resources/static/ 目录, /src/main/resources/static/css/main.css文件代码如下 -

h1{
    font-size: 20pt;
}
h2{
    font-size: 16pt;
}

对于属性文件,放入 /src/main/resources/ 目录中,
/src/main/resources/application.properties 文件中的代码内容如下 -

welcome.message: Hello, Spring Boot

注意:阅读此Spring Boot服务静态内容以了解资源映射。



5. 运行演示


启动Spring Boot Web应用程序,使用Maven命令:mvn spring-boot:run,运行结果输出如下-

D:\workspace\web-thymeleaf>mvn spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Spring Boot Web Thymeleaf ?? 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli) > test-compile @ web-t
hymeleaf >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ web-thymeleaf ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ web-thymeleaf ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ web-thymelea
f ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\workspace\web-thymeleaf\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ web-thymeleaf ---

[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli) < test-compile @ web-t
hymeleaf <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli) @ web-thymeleaf ---
[INFO] Attaching agents: []

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.2.RELEASE)

2018-08-08 11:35:18.219  INFO 11240 --- [  restartedMain] com.th.SpringBootWebApplication
         : Starting SpringBootWebApplication on SZ10PD0703 with PID 11240 (D:\workspace\we
b-thymeleaf\target\classes started by nicoletang in D:\workspace\web-thymeleaf)
2018-08-08 11:35:18.235  INFO 11240 --- [  restartedMain] com.th.SpringBootWebApplication
         : No active profile set, falling back to default profiles: default
2018-08-08 11:35:18.703  INFO 11240 --- [  restartedMain] ationConfigEmbeddedWebApplicatio
nContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWe
bApplicationContext@5e9a1d78: startup date [Wed Aug 08 11:35:18 CST 2018]; root of context
 hierarchy
2018-08-08 11:35:20.668  INFO 11240 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletC
ontainer : Tomcat initialized with port(s): 8080 (http)
2018-08-08 11:35:20.684  INFO 11240 --- [  restartedMain] o.apache.catalina.core.StandardS
ervice   : Starting service Tomcat
2018-08-08 11:35:20.684  INFO 11240 --- [  restartedMain] org.apache.catalina.core.Standar
dEngine  : Starting Servlet Engine: Apache Tomcat/8.5.6
2018-08-08 11:35:21.027  INFO 11240 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[
/]       : Initializing Spring embedded WebApplicationContext
2018-08-08 11:35:21.042  INFO 11240 --- [ost-startStop-1] o.s.web.context.ContextLoader
         : Root WebApplicationContext: initialization completed in 2339 ms
2018-08-08 11:35:21.245  INFO 11240 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrat
ionBean  : Mapping servlet: 'dispatcherServlet' to [/]
2018-08-08 11:35:21.245  INFO 11240 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrati
onBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-08-08 11:35:21.245  INFO 11240 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrati
onBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-08-08 11:35:21.245  INFO 11240 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrati
onBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-08-08 11:35:21.245  INFO 11240 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrati
onBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-08-08 11:35:21.573  INFO 11240 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandle
rAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.Annota
tionConfigEmbeddedWebApplicationContext@5e9a1d78: startup date [Wed Aug 08 11:35:18 CST 20
18]; root of context hierarchy
2018-08-08 11:35:21.651  INFO 11240 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandle
rMapping : Mapped "{[/]}" onto public java.lang.String com.th.WelcomeController.welcome(ja
va.util.Map<java.lang.String, java.lang.Object>)
2018-08-08 11:35:21.651  INFO 11240 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandle
rMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.ut
il.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.Bas
icErrorController.error(javax.servlet.http.HttpServletRequest)
2018-08-08 11:35:21.651  INFO 11240 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandle
rMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.se
rvlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHt
ml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-08-08 11:35:21.697  INFO 11240 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandler
Mapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.w
eb.servlet.resource.ResourceHttpRequestHandler]
2018-08-08 11:35:21.697  INFO 11240 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandler
Mapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servl
et.resource.ResourceHttpRequestHandler]
2018-08-08 11:35:21.760  INFO 11240 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandler
Mapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframewo
rk.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-08 11:35:22.337  INFO 11240 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServ
er       : LiveReload server is running on port 35729
2018-08-08 11:35:22.415  INFO 11240 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporte
r        : Registering beans for JMX exposure on startup
2018-08-08 11:35:22.586  INFO 11240 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletC
ontainer : Tomcat started on port(s): 8080 (http)
2018-08-08 11:35:22.602  INFO 11240 --- [  restartedMain] com.th.SpringBootWebApplication
         : Started SpringBootWebApplication in 4.866 seconds (JVM running for 5.591)

运行成功后,打开浏览器访问:http://localhost:8080 ,没有问题应该会看到以下输出页面 -
这里写图片描述


6. 构建可执行JAR


打包项目以创建可执行的JAR文件。使用Maven命令:mvn clean package,

D:\workspace\web-thymeleaf>mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Spring Boot Web Thymeleaf ?? 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ web-thymeleaf ---
[INFO] Deleting D:\workspace\web-thymeleaf\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ web-thymeleaf ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ web-thymeleaf ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to D:\workspace\web-thymeleaf\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ web-thymelea
f ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\workspace\web-thymeleaf\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ web-thymeleaf ---

[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ web-thymeleaf ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ web-thymeleaf ---
[INFO] Building jar: D:\workspace\web-thymeleaf\target\web-thymeleaf-1.0.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.4.2.RELEASE:repackage (default) @ web-thymeleaf ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.674 s
[INFO] Finished at: 2018-08-08T14:11:06+08:00
[INFO] Final Memory: 29M/212M
[INFO] ------------------------------------------------------------------------

D:\workspace\web-thymeleaf>

然后再执行

D:\workspace\web-thymeleaf>java -jar target/web-thymeleaf-1.0.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.2.RELEASE)

2018-08-08 14:11:36.418  INFO 7768 --- [           main] com.th.SpringBootWebApplication
        : Starting SpringBootWebApplication v1.0 on SZ10PD0703 with PID 7768 (D:\workspace
\web-thymeleaf\target\web-thymeleaf-1.0.jar started by nicoletang in D:\workspace\web-thym
eleaf)
2018-08-08 14:11:36.434  INFO 7768 --- [           main] com.th.SpringBootWebApplication
        : No active profile set, falling back to default profiles: default
2018-08-08 14:11:37.167  INFO 7768 --- [           main] ationConfigEmbeddedWebApplication
Context : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWeb
ApplicationContext@2328c243: startup date [Wed Aug 08 14:11:37 CST 2018]; root of context
hierarchy
2018-08-08 14:11:39.944  INFO 7768 --- [           main] s.b.c.e.t.TomcatEmbeddedServletCo
ntainer : Tomcat initialized with port(s): 8080 (http)
2018-08-08 14:11:39.975  INFO 7768 --- [           main] o.apache.catalina.core.StandardSe
rvice   : Starting service Tomcat
2018-08-08 14:11:39.975  INFO 7768 --- [           main] org.apache.catalina.core.Standard
Engine  : Starting Servlet Engine: Apache Tomcat/8.5.6
2018-08-08 14:11:40.241  INFO 7768 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/
]       : Initializing Spring embedded WebApplicationContext
2018-08-08 14:11:40.241  INFO 7768 --- [ost-startStop-1] o.s.web.context.ContextLoader
        : Root WebApplicationContext: initialization completed in 3074 ms
2018-08-08 14:11:40.521  INFO 7768 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrati
onBean  : Mapping servlet: 'dispatcherServlet' to [/]
2018-08-08 14:11:40.537  INFO 7768 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistratio
nBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-08-08 14:11:40.537  INFO 7768 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistratio
nBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-08-08 14:11:40.537  INFO 7768 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistratio
nBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-08-08 14:11:40.537  INFO 7768 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistratio
nBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-08-08 14:11:40.990  INFO 7768 --- [           main] s.w.s.m.m.a.RequestMappingHandler
Adapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.Annotat
ionConfigEmbeddedWebApplicationContext@2328c243: startup date [Wed Aug 08 14:11:37 CST 201
8]; root of context hierarchy
2018-08-08 14:11:41.130  INFO 7768 --- [           main] s.w.s.m.m.a.RequestMappingHandler
Mapping : Mapped "{[/]}" onto public java.lang.String com.th.WelcomeController.welcome(jav
a.util.Map<java.lang.String, java.lang.Object>)
2018-08-08 14:11:41.130  INFO 7768 --- [           main] s.w.s.m.m.a.RequestMappingHandler
Mapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.uti
l.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.Basi
cErrorController.error(javax.servlet.http.HttpServletRequest)
2018-08-08 14:11:41.130  INFO 7768 --- [           main] s.w.s.m.m.a.RequestMappingHandler
Mapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.ser
vlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtm
l(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-08-08 14:11:41.177  INFO 7768 --- [           main] o.s.w.s.handler.SimpleUrlHandlerM
apping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.we
b.servlet.resource.ResourceHttpRequestHandler]
2018-08-08 14:11:41.177  INFO 7768 --- [           main] o.s.w.s.handler.SimpleUrlHandlerM
apping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servle
t.resource.ResourceHttpRequestHandler]
2018-08-08 14:11:41.239  INFO 7768 --- [           main] o.s.w.s.handler.SimpleUrlHandlerM
apping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframewor
k.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-08 14:11:41.957  INFO 7768 --- [           main] o.s.j.e.a.AnnotationMBeanExporter
        : Registering beans for JMX exposure on startup
2018-08-08 14:11:42.222  INFO 7768 --- [           main] s.b.c.e.t.TomcatEmbeddedServletCo
ntainer : Tomcat started on port(s): 8080 (http)
2018-08-08 14:11:42.238  INFO 7768 --- [           main] com.th.SpringBootWebApplication
        : Started SpringBootWebApplication in 6.88 seconds (JVM running for 7.752)

运行成功后,打浏览器再次访问: http://localhost:8080 ,没有问题应该会看到以下输出页面
这里写图片描述




相关文章:

Spring Boot入门实战:快速搭建Hello World网页应用 Spring Initializr 是一个在线工具,用于生成 Spring Boot 项目骨架。访问,可以自定义:项目类型(Maven / Gradle)Java 版本Spring Boot 版本项目依赖(如 Web、JPA、Security)生成后下载的 zip 文件可以直接导入 IDE 使用。Spring允许开发者自定义组合注解,提高代码的可读性和复用性。自定义注解本质上是的封装。提高了开发效率,使代码更具语义化。 阅读详情

相关推荐

Springboot-helloworld案例

  创建独立的 Spring 应用程序   嵌入的 Tomcat,无需部署 WAR 文件   简化 Maven 配置   自动配置 Spring   提供生产就绪型功能,如指标,健康检查和外部配置   开箱即用,没有代码生成,也无需 XML 配置。

SpringBoot + Thymeleaf 之 HelloWorld

目录 ■相关知识 ■构造 ■代码 java html pom yml ■相关知识 Java学习(更新中)_sun0322-优快云博客 使用JDK中的 keytool【创建证书】・【查看】・【使用】_sun0322-优快云博客 ■构造 ■代码 java 注意点:不能使用@RestController package com.sxz.test.one; import java.time.LocalDateTime; import javax.servlet.ht...

sun0322 5278

springboot的helloworld入门程序

通过基本的springboot的配置,实现简单的helloworld入门程序,本人亲自测试过,易上手,有文档说明

Thymeleaf 之 HelloWorld

本文章来自【知识林】基本每一个知识点的学习都是从HelloWorld开始的,HelloWorld级别的例子只是让人清楚这个知识点的概要及简单的实现流程。本例子也不例外,通过这个例子对Thymeleaf有个简单的认识,后面逐步深入。 Maven依赖 在pom.xml文件中需要引入Thymeleaf的依赖配置<dependency> <groupId>org.springframework.bo

知识林www.zslin.com 1331

springboot-hello-world:springboot的一个简单例子

springboot-hello-world CI / CD管道的简单示例。 我在这里所做的一切非常简单。 这只是通过以下流程部署CI / CD管道的测试: PC-> Github-> Jenkins-> Docker-> Kubernetes 运行代码 整个项目可以使用docker运行。 为了建立项目,请运行 mvn包 由于来自spotify的dockerfile-maven-plugin的帮助,这会将整个项目构建到一个docker映像中,该文件允许将docker构建并将推送过程绑定到一个maven构建过程。 与詹金斯一起建筑 添加了一个一旦从Github提取完成,就可以自动在Jenkins上进行管道构建。 部署到Kubernetes 添加了一个kubernetes文件,该文件将设置副本并自动启动服务。 要创建部署和服务,您需要做两件事以在本地进行测试: 迷你库 本地kub

Spring boot 示例 官方 Demo

spring-boot-helloWorld:spring-boot的helloWorld版本 spring-boot-mybaits-annotation:注解版本 spring-boot-mybaits-xml:xml配置版本 spring-boot-mybatis-mulidatasource:springboot+mybatis多数据源最简解决方案 spring-boot-mybatis-annotation-mulidatasource:springboot+mybatis(注解版)多数据源最简解决方案 spring-boot-thymeleaf:simple spring boot thymeleaf demo spring-boot-jpa-thymeleaf-curd:spring boot + jpa + thymeleaf 增删改查示例 spring-boot-rabbitmq:spring boot和rabbitmq各种消息应用案例 spring-boot-scheduler:spring boot和定时任务案例 spring-boot-web:web开发综合使用案例 spring-boot-mail:spring boot和邮件服务 spring-boot-mongodb:spring boot和mongodb的使用 spring-boot-multi-mongodb:spring boot和mongodb多数据源的使用 spring-boot-package-war:spring-boot打包成war包示例 spring-boot-shiro:springboot 整合shiro rbac示例 spring-boot-file-upload:使用Spring Boot 上传文件示例 spring-boot-fastDFS:Spring Boot 整合FastDFS示例 spring-boot-actuator:Spring Boot Actuator 使用示例 spring-boot-admin-simple:Spring Boot Admin 的使用示例

Spring Boot Hello World示例– Thymeleaf

在本文中,我们将向您展示如何使用Thymeleaf视图,嵌入式Tomcat开发Spring Boot Web应用程序并将其打包为可执行的JAR文件。 使用的技术: Spring Boot 2.1.2发布 Spring5.1.4。发布 Thymeleaf 3.0.11。发布 Tomcat嵌入9.0.14 JUnit 4.12 Maven 3 Java 8 ...

一名可爱的技术搬运工 258

springboot项目demo(HelloWord 入门)

包含通过spring框架,对web项目的所有基本功能使用,包括过滤器、定时器、url访问、redis集成、redisSession集群、日志文件、项目初始化监听、mybatis集成。通过一个demo基本花费半天时间入门springboot. 项目导入sts(集成了springboot开发插件的eclipse)后,直接通过springboot启动运行就可以。jdk必须1.8及以上

Thymeleaf简介-HelloWorld基本语法:

JSP、Freemarker、Velocity等等,它们有一个共同的名字:服务器端模板技术。官网地址Thymeleaf优势SpringBoot官方推荐使用的视图模板技术,和SpringBoot完美整合。不经过服务器运算仍然可以直接查看原始值,对前端工程师更友好。

业精于勤,荒于嬉 303

别再踩坑了!Win10下用阿狸狗V3.2.6安装Cadence SPB 17.4的保姆级避坑指南

本文提供了Win10系统下使用阿狸狗V3.2.6安装Cadence SPB 17.4的详细避坑指南,涵盖环境准备、安装失败清理、分步安装与问题诊断、授权配置及典型故障排除等内容,帮助用户顺利完成安装并避免常见错误。

weixin_32576389的博客 359

Unity通过Vosk实现离线语音识别方法

以下是一个使用 Unity 和 Vosk(一个开源的离线语音识别库)的简单示例。将Vosk的DLL文件(如libvosk.dll、vosk.dll等)放入Assets/Plugins文件夹中。通过以上步骤,你可以在Unity中实现一个简单的离线语音识别功能。音频格式:确保录音的音频格式与Vosk模型要求的格式一致(通常是16kHz、16bit单声道)。首先,你需要下载Vosk的语音识别模型。在Assets文件夹中创建一个Plugins文件夹,用于存放Vosk的DLL文件。打开Unity并创建一个新的项目。

qq_39515892的博客 2070

SpringBoot入门案例--HelloWorld

提示:搭建整个SpringBoot项目,注意选择SpringBoot版本号,版本号不要选择太高,一定要将搭建选择的项目名称,jdk版本,以及SpringWeb跟POM文件对应理解。项目中@RestController ,@GetMapping需要自行百度理解为什么使用注解,注解含义是什么,什么时候用到注解等等。。

qq_42211536的博客 927

利用SPSS实现逻辑回归,树模型,以及广义线性模型

本案例是IBM SPSS数据分析与挖掘实战案例精粹----第九章的学习记录 案例背景:分析出导致急救后迟发性颅脑损伤的主要影响因素,共有201项案例: 分析思路:先使用logistic回归模型进行影响因素筛选,然后利用分类树探索自变量中是否存在交互作用,最后利用广义线性模型过程拟合带交互项的Logistic回归模型 字段:性别,年龄,收缩压,舒张压,血小板,脑挫伤,中线位移,脑肿胀,入院意识,是否手术急救,其余急救措施,是否出现迟发性脑损伤; ...

hepan_defeng的博客 1万+

IDEA 使用Spring Boot框架实现hello world

一、下载IDEA 1.windows版本官网下载链接Thank you for downloading IntelliJ IDEA! (jetbrains.com) 2.下载完成以后运行安装,安装好了之后可以点击JDaccount 注册一个账号,之后登录账号,选择start trial就可以30天试用 二、下载java和maven并配置环境变量 网上教程都挺多的,这里不再多提 三,开启IDEA的helloworld 1.在idea里面文件(file),新建一个项目,在左侧选择spring in

lkj8546的博客 3374

Ferry工单平台部署

ferry工单平台部署

运维求生之路 1897

局域网ip冲突检测工具_python 小工具实现 windows笔记本与 ipad数据互传

宅在家没事的时候就开始琢磨ipad的进阶使用,由于没有mac无法隔空投送,ipad与windows的数据交互表现极差,所以设计了这个ftp小工具。当然,这个工具不仅仅能用于windows与ipad,还可以用于局域网任意两台设备之间程序源码与下载见文章末尾使用说明windows端:biubiubiu.exeipad端: appsotre下载 FE文件管理器windows端操作在c盘下创建ftp目录...

weixin_39866265的博客 4435

Thymeleaf介绍

Thymeleaf介绍 thymeleaf是一个XML/XHTML/HTML5模板引擎,可用于Web与非Web环境中的应用开发。它是一个开源的Java库,基于Apache License 2.0许可,由Daniel Fernández创建,该作者还是Java加密库Jasypt的作者。 Thymeleaf提供了一个用于整合Spring MVC的可选模块,在应用开发中,你可以使用Thymeleaf来完全代替JSP或其他模板引擎,如Velocity、FreeMarker等。Thymeleaf的主要目标在于提供一.

chinusyan的专栏 4万+

别再死记硬背了!用‘小乌龟’实战图解ROS1核心指令(rosnode/rostopic/rosparam保姆级手册)

本文通过经典的turtlesim乌龟仿真器,以可视化实战方式讲解ROS1核心指令(rosnode/rostopic/rosparam),帮助初学者摆脱死记硬背,在操控乌龟的过程中轻松掌握节点管理、话题通信和参数设置等ROS1核心概念。

weixin_28731223的博客 370

Spring Boot 示例项目教程

Spring Boot 示例项目教程 项目介绍 Spring Boot 示例项目(https://github.com/topsale/spring-boot-samples)是一个旨在帮助开发者快速学习和掌握 Spring Boot 框架的开源项目。该项目包含了多个示例,涵盖了从基础的 Hello World 应用到复杂的数据库操作、Web 开发、消息队列处理等多个方面。每个示例都以最简单、最实...

gitblog_00365的博客 1036

configure: error: no acceptable C compiler found in $PATH解决方案

本文主要介绍了configure: error: no acceptable C compiler found in $PATH解决方案,希望能对使用Linux的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 4万+

【系统分析师】写作框架:软件设计模式及其应用

本文围绕"软件设计模式及其应用"展开论述。首先介绍了近三年参与的某软件开发项目背景及个人承担的系统设计工作。其次系统阐述了设计模式的三大分类:创建型(如工厂方法、单例模式)、结构型(如适配器、装饰器模式)和行为型(如观察者、策略模式),重点分析了各类模式的特点和典型应用场景。最后结合项目实践,详细说明了采用的三种设计模式的具体实施过程及效果,包括提高代码复用性、降低耦合度等优势。文章还总结了项目经验,指出存在的不足及改进方向,强调合理运用设计模式对构建高质量软件系统的重要性。全文通过理论

数据知道的博客 5061

Spring Boot学习总结之整合thymeleaf

对于thymeleaf的简介前一篇文章里面已经讲过了,本篇文章的内容是快速和Spring Boot整合 。(一)添加依赖&lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artif...

米不开朗基罗的博客 497

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

SpringBoot+thymeleaf模板引擎输出html中的Hello World!

pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> controller.java package com.e...

新手村的博客 502

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

Spring Boot Hello World示例–胡子

一个Spring Boot Web应用程序示例,使用embedded Tomcat + Mustache template engine ,并打包为可执行JAR文件。 使用的技术: Spring Boot 1.5.2。发布 春天4.3.7。发布 胡子1.13 胸腺2.1.5。发布 Tomcat嵌入8.5.11 Maven 3 Java 8 注意 ...

一名可爱的技术搬运工 300

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

idea 新建thymeleaf_在idea下搭建Spring Boot+Spring MVC+thymeleaf

今天大兄弟来讲一下在idea下,使用Spring Boot ,搭建Spring MVC+thymeleaf。在Java开发领域,Spring Boot算得上是一颗耀眼的明星了。Spring Boot集成了大量的第三方库的配置,达到了几乎可以零配置的开箱即用的效果,包括我们今天要讲的Spring MVC和thymeleaf。首先在idea下新建项目,如图,点击下一步:在这里根据需求自己填写配置,点击...

weixin_36072221的博客 1102

Springboot的第一个Hello World程序

首先大概介绍一个Intellij为我们生成的目录结构: 上图中我通过标注的形式介绍了几个基本的结构,现在我们介绍几个主要目录: /src/main下面是主要的代码文件和网页模板。 Java下是逻辑控制、数据表Model等代码。resource里是静态资源,其中static里是CSS、JS等。template里就是HTML模板啦~ 现在开始写第一个Hello Worl

Soul_Feng的博客 1066
上一篇: Spring Boot将WAR文件部署到Tomcat(十一)
下一篇: Spring Boot非web应用程序实例(十三)
CZ__
博客等级 码龄9年 97粉丝 114原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值