当前位置: 首页 > 软件库 > Web应用开发 > >

spring-boot-blog

授权协议 Apache-2.0 License
开发语言 Java
所属分类 Web应用开发
软件类型 开源软件
地区 不详
投 递 者 司空瑾瑜
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Spring Boot Blog Demo

About

This is a demo project for practicing Spring Boot + Thymeleaf.The idea was to build some basic blogging platform.

It was made using Spring Boot, Spring Security, Thymeleaf, Spring Data JPA, Spring Data REST and Docker.Database is in memory H2.

There is a login and registration functionality included.

User has his own blog page, where he can add new blog posts.Every authenticated user can comment on posts made by other users.Home page is paginated list of all posts.Non-authenticated users can see all blog posts, but cannot add new posts or comment.

Screenshot 1

Screenshot 1

Configuration

Configuration Files

Folder src/resources/ contains config files for blog-demo Spring Boot application.

  • src/resources/application.properties - main configuration file. Here it is possible to change admin username/password,as well as change the port number.

How to run

There are several ways to run the application. You can run it from the command line with included Maven Wrapper, Maven or Docker.

Once the app starts, go to the web browser and visit http://localhost:8090/home

Admin username: admin

Admin password: admin

User username: user

User password: password

Maven Wrapper

Using the Maven Plugin

Go to the root folder of the application and type:

$ chmod +x scripts/mvnw
$ scripts/mvnw spring-boot:run

Using Executable Jar

Or you can build the JAR file with

$ scripts/mvnw clean package

Then you can run the JAR file:

$ java -jar target/blog-demo-0.0.1-SNAPSHOT.jar

Maven

Open a terminal and run the following commands to ensure that you have valid versions of Java and Maven installed:

$ java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
$ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_102, vendor: Oracle Corporation

Using the Maven Plugin

The Spring Boot Maven plugin includes a run goal that can be used to quickly compile and run your application.Applications run in an exploded form, as they do in your IDE.The following example shows a typical Maven command to run a Spring Boot application:

$ mvn spring-boot:run

Using Executable Jar

To create an executable jar run:

$ mvn clean package

To run that application, use the java -jar command, as follows:

$ java -jar target/blog-demo-0.0.1-SNAPSHOT.jar

To exit the application, press ctrl-c.

Docker

It is possible to run blog-demo using Docker:

Build Docker image:

$ mvn clean package
$ docker build -t blog-demo:dev -f docker/Dockerfile .

Run Docker container:

$ docker run --rm -i -p 8090:8090 \
      --name blog-demo \
      blog-demo:dev
Helper script

It is possible to run all of the above with helper script:

$ chmod +x scripts/run_docker.sh
$ scripts/run_docker.sh

Docker

Folder docker contains:

  • docker/blog-demo/Dockerfile - Docker build file for executing blog-demo Docker image.Instructions to build artifacts, copy build artifacts to docker image and then run app on proper port with proper configuration file.

Util Scripts

  • scripts/run_docker.sh.sh - util script for running blog-demo Docker container using docker/Dockerfile

Tests

Tests can be run by executing following command from the root of the project:

$ mvn test

Helper Tools

HAL REST Browser

Go to the web browser and visit http://localhost:8090/

You will need to be authenticated to be able to see this page.

H2 Database web interface

Go to the web browser and visit http://localhost:8090/h2-console

In field JDBC URL put

jdbc:h2:mem:blog_simple_db

In /src/main/resources/application.properties file it is possible to change bothweb interface url path, as well as the datasource url.

  • 1、jdbc JDBC是一种用于执行SQL语句的API,可以为多种关系数据库提供统一访问,它是由一组用Java语言编写的类和接口。是Java访问数据库的标准规范。 JDBC是Java提供的一种标准规范,具体的实现由各个数据库厂商去实现。对开发者来说屏蔽了不同数据库之间的区别,可以使用相同的方式(Java API)去操作不同的数据库。两个设备之间要进行通信需要驱动,不同数据库厂商对JDBC的实现类就

  • IDEA搭建spring-boot maven报错Project ‘org.springframework.boot:spring-boot-starter-parent:2.2.0.RELEASE’ not found 在新建springboot项目引入RELEASE版本时,有几率从远程仓库下载jar包出错,导致jar包无法导入.即使我把相关的包都删完,都不行,要么换个仓库,要么换个版本.下面给

  • 创建SpringBoot项目出现的问题(Could not transfer artifact org.springframework.boot:spring-boot-starter-parent) 前言:之前创建SpringBoot项目也出现过此问题,但是换了一个maven仓库好使了,但是没过多久那个仓库访问不了了,然后项目就开始报错。这几天自己创建项目又出现了这个问题,感觉再不彻底解决,人都

  • 1、首先需要查看一下当前项目JDK版本与环境中的JDK版本是否一致,参考此连接https://blog.csdn.net/gao_jun1/article/details/109997200 注意 pom.xml中的jdk版本也需要对应 2. 检查一下maven配置路径 3. 如果maven下的dependencies爆红,此时处理办法为先删掉pom.xml中的依赖,接着重置一下maven会发现d

  • SpringBootMonitor spring-boot-admin源码分析及单机监控spring-boot-monitor的实现(一) spring-boot-admin源码分析及单机监控spring-boot-monitor的实现(二) spring-boot-admin源码分析及单机监控spring-boot-monitor的实现(三) 1.spring-boot-admin配置分析 sp

 相关资料
  • Spring Boot 项目旨在简化创建产品级的 Spring 应用和服务。你可通过它来选择不同的 Spring 平台。可创建独立的 Java 应用和 Web 应用,同时提供了命令行工具来允许 'spring scripts'. 下图显示 Spring Boot 在 Spring 生态中的位置: 该项目主要的目的是: 为 Spring 的开发提供了更快更广泛的快速上手 使用默认方式实现快速开发 提

  • 本文向大家介绍Spring Boot集成 Spring Boot Admin 监控,包括了Spring Boot集成 Spring Boot Admin 监控的使用技巧和注意事项,需要的朋友参考一下 【前言】 程序开发完实现相应的功能只是一个部分,如何让系统在线上运行更好创造更高的价值是另外一个部分;监控是一个生产级项目避不可少重要组成部分;最近研究一下针对SpringBoot的监控项目---Sp

  • 我正在努力学习spring boot,我注意到有两种选择。 > spring-boot-starter-web-根据文档,它支持全栈web开发,包括Tomcat和web-mvc spring-Boot-Starter-Tomcat 既然#1支持Tomcat,为什么要使用#2呢? 有什么不同? 谢谢

  • 主要内容:starter,spring-boot-starter-parent传统的 Spring 项目想要运行,不仅需要导入各种依赖,还要对各种 XML 配置文件进行配置,十分繁琐,但 Spring Boot 项目在创建完成后,即使不编写任何代码,不进行任何配置也能够直接运行,这都要归功于 Spring Boot 的 starter 机制。本节我们将对 stater 进行介绍。 starter Spring Boot 将日常企业应用研发中的各种场景都抽取出来,做成一个个的

  • 我遇到空指针异常,不知道如何克服这个问题并混淆代码。你有什么想法吗? 我正在努力混淆一些库的[Maven]Spring启动项目与ProGuard(proGuard proGuard-maven-plugin) 堆栈跟踪: POM构建插件:

  • 我是一个Spring的新蜜蜂,试图将gs-rest-service-complete导入到我的STS中,我可以导入,但在pom.xml中得到编译错误 无法传输工件org.springframework.boot:spring-boot-starter-parent:POM:1.2.3。release from/to spring-releases(https://repo.spring.io/li