spring-security-react-ant-design-polls-app

使用 Spring Boot、Spring Security、JWT、React 和 Ant 设计构建的全栈投票应用程序。(Full Stack Polls App built using Spring Boot, Spring Security, JWT, React, and Ant Design.)

Github星跟蹤圖

教程

作者已经写了一个完整的教程系列, 这个应用程序在 CalliCoder 博客:

设置Spring Boot后端应用程序的步骤(polling-app-server)

  1. 克隆应用程序
    git clone https://github.com/callicoder/spring-security-react-ant-design-polls-app.git
    cd polling-app-server    
  2. 创建 MySQL 数据库
    create database polling_app    
  3. 根据 MySQL 安装更改 MySQL 用户名和密码
    • 打开 src/main/resources/application.properties 文件;
    • 根据 mysql 安装更改 spring.datasource.usernamespring.datasource.password 属性。
  4. 运行应用程序 您可以通过键入以下命令来运行 spring boot 应用程序 -
    mvn spring-boot:run    
    服务器将在端口8080上启动。您还可以以 jar 文件的形式打包应用程序, 然后像这样运行它:
    mvn package
    java -jar target/polls-0.0.1-SNAPSHOT.jar    
  5. 默认角色 spring boot app 使用 spring security 驱动的基于角色的授权, 若要在数据库中添加默认角色, 作者在 src/main/resources/data.sql 文件中添加了以下 sql 查询。Spring boot 将在启动时自动执行此脚本:
    INSERT IGNORE INTO roles(name) VALUES ( 'ROLE_USER');
    INSERT IGNORE INTO roles(name) VALUES ( 'ROLE_ADMIN');    
    默认情况下, 任何注册到应用的新用户都会被分配为 ROLE_USER

设置React前端应用程序的步骤(polling-app-client)

首先转到polling-app-client文件夹:

cd polling-app-client

然后键入以下命令以安装依赖项并启动应用程序:

npm install && npm start

前端服务器将在端口3000上启动。

主要指標

概覽
名稱與所有者callicoder/spring-security-react-ant-design-polls-app
主編程語言Java
編程語言JavaScript (語言數: 5)
平台Cross-platform, Linux, Mac, Unix-like, Windows
許可證
所有者活动
創建於2018-02-28 05:01:35
推送於2023-12-10 06:23:57
最后一次提交2021-10-14 00:17:13
發布數0
用户参与
星數1.8k
關注者數64
派生數1.1k
提交數71
已啟用問題?
問題數27
打開的問題數25
拉請求數1
打開的拉請求數22
關閉的拉請求數37
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

Building a Full Stack Polls app similar to twitter polls with Spring Boot, Spring Security, JWT, React and Ant Design

App Screenshot

Tutorials

I've written a complete tutorial series for this application on The CalliCoder Blog -

Steps to Setup the Spring Boot Back end app (polling-app-server)

  1. Clone the application

    git clone https://github.com/callicoder/spring-security-react-ant-design-polls-app.git
    cd polling-app-server
    
  2. Create MySQL database

    create database polling_app
    
  3. Change MySQL username and password as per your MySQL installation

    • open src/main/resources/application.properties file.

    • change spring.datasource.username and spring.datasource.password properties as per your mysql installation

  4. Run the app

    You can run the spring boot app by typing the following command -

    mvn spring-boot:run
    

    The server will start on port 8080.

    You can also package the application in the form of a jar file and then run it like so -

    mvn package
    java -jar target/polls-0.0.1-SNAPSHOT.jar
    
  5. Default Roles

    The spring boot app uses role based authorization powered by spring security. To add the default roles in the database, I have added the following sql queries in src/main/resources/data.sql file. Spring boot will automatically execute this script on startup -

    INSERT IGNORE INTO roles(name) VALUES('ROLE_USER');
    INSERT IGNORE INTO roles(name) VALUES('ROLE_ADMIN');
    

    Any new user who signs up to the app is assigned the ROLE_USER by default.

Steps to Setup the React Front end app (polling-app-client)

First go to the polling-app-client folder -

cd polling-app-client

Then type the following command to install the dependencies and start the application -

npm install && npm start

The front-end server will start on port 3000.