Language / Frameworks / Tools / Database | Version |
---|---|
Java | 11.0.2 or later |
Javac | 11.0.2 or later |
Apache Maven | 3.6.3 |
Spring Boot | 2.4.4 |
MySQL | 8.0.23 |
Redis | 6.2.4 |
elasticsearch | 7.13.1 |
logstash | 7.13.1 |
kibana | 7.13.1 |
-
Editor: IDEA
- install a plugin: click File -> Settings -> plugins
- useful plugins:
- Spring Assistant
-
Java (version: 11 or later)
- install JDK
- set up environment path for JDK
- type
java -version
andjavac -version
to make sure these 2 commands are installed.
-
Apache Maven (version: 3.6.3)
- maven install dependencies based on pom.xml . All the dependency files put in the folder named ".m2", like
/Users/[username]/.m2/repository
.
- install Maven
- set up environment path for Maven. (e.g
export PATH="$PATH:/Users/win/project/apache-maven-3.6.3/bin"
) - type
mvn -v
to make sure it's installed.
- maven install dependencies based on pom.xml . All the dependency files put in the folder named ".m2", like
-
Spring Boot 2.4.4 RELEASE
-
MySQL Database (version: 8.0.23)
-
Redis (version: 6.2.4)
-
install redis by Brew
- brew update
- brew install redis
-
Run Redis server
brew services start redis
-
Stop Redis server
brew services stop redis
-
Redis client
redis-cli
-
-
ELK
- elasticsearch (version: 7.13.1)
- install via homebrew
- related commands:
- brew services start elastic/tap/elasticsearch-full (or just run: elasticsearch)
- brew services stop elasticsearch
- brew info elasticsearch
- after start,
http://localhost:9200/
should be available
- logstash (version: 7.13.1)
- install via homebrew
- related commands:
- brew services start elastic/tap/logstash-full
cd src/main/resources logstash -f logstash.conf
- after start,
http://localhost:9600/
should be available
- kibana (version: 7.13.1)
- install via homebrew
- related commands:
- brew install elastic/tap/kibana-full
- brew services start kibana-full
- after start,
http://localhost:5601
should be available. - test:
- access http://localhost:5601/app/dev_tools#/console
- try
GET /_cat/health?v=true
on console.
- elasticsearch (version: 7.13.1)
Please check pox.xml
file which includes the required dependencies.
- Open IDEA
- File > Project structure > Artifacts, click "+", choose "JAR", choose "From modules with dependencies".
- Choose Main Class "WebsysApplication"
- Click "OK" twice
- Click the "Maven" panel on the right side, click "Lifecycle > package" then wait for the packaging process. Once it finished, will show something like this:
(ref: README/packaging1.png, packaging2.png)
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ demo ---
[INFO] Building jar: /Users/[username]/project/websys/target/demo-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.4:repackage (repackage) @ demo ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
use the jar location path, and run:
java -jar demo-0.0.1-SNAPSHOT.jar
Some unnecessary local information needs to be hidden so that the application.properties
file ignored by default.
Please copy src/main/resources/application.properties.example
to src/main/resources/application.properties
and update some of needed info such as user and password by your preferences.
- Dump mysql schema
mysqldump -u user -h localhost --no-data -p websys > database.sql
METHOD | ENDPOINT |
---|---|
POST | /users/signup |
POST | /users/login |
GET | /users/me |
GET | /users/parse |
GET | /users/refresh |
DEL | /users/{username} |
GET | /news |
GET | /news/{id} |
POST | /news |
PUT | /news/{id} |
DELETE | /news/{id} |
GET | /products |
GET | /products/{id} |
POST | /products/ |
PUT | /products/{id} |
DELETE | /products/{id} |
GET | /audit |
GET | /audit/search?page={page}&limit={10}&query={query} |
GET | /audit/eventType/{event_type} |
GET | /audit/username/{username} |
GET | /audit/{id} |
Request Body (application/json)
{
"email": "[email protected]",
"password": "12345678",
"roles": [
{"id": 2,"name": "ROLE_SYSTEM_ADMIN"}
],
"username": "superadmin"
}
RequestParam (application/x-www-form-urlencoded)
(all default username please reference data.sql)
username: "admin"
password: "12345678"
Response format:
{
"id": 1,
"username": "superadmin",
"email": "[email protected]",
"permissions": [
{
"name": "admin-users-read",
"resource": "users"
},
{
"name": "admin-users-write",
"resource": "users"
},
{
"name": "admin-users-delete",
"resource": "users"
},
{
"name": "admin-users-all",
"resource": "users"
},
{
"name": "news-read",
"resource": "news"
},
{
"name": "news-write",
"resource": "news"
},
{
"name": "news-delete",
"resource": "news"
},
{
"name": "news-users-all",
"resource": "news"
},
{
"name": "product-read",
"resource": "product"
},
{
"name": "product-write",
"resource": "product"
},
{
"name": "product-delete",
"resource": "product"
},
{
"name": "product-all",
"resource": "product"
}
],
"enabled": true,
"authorities": [
{
"authority": "ROLE_SYSTEM_ADMIN"
},
{
"authority": "ROLE_ADMIN"
},
{
"authority": "ROLE_ADMIN_MARKETING"
},
{
"authority": "ROLE_ADMIN_SALES"
}
],
"accountNonExpired": false,
"accountNonLocked": false,
"credentialsNonExpired": false,
"permissionsNames": [
"admin-users-read",
"admin-users-write",
"admin-users-delete",
"admin-users-all",
"news-read",
"news-write",
"news-delete",
"news-users-all",
"product-read",
"product-write",
"product-delete",
"product-all"
]
}
Response format:
{
"sub": "moving3",
"auth": [
{
"authority": "ROLE_ADMIN_MARKETING"
}
],
"exp": 1621875598,
"iat": 1621871998
}
After boot this web application, the swagger page is available on http://localhost:{YOUR_PORT}/swagger-ui.html