315 lines
13 KiB
Markdown
315 lines
13 KiB
Markdown
# sisvietnamvn
|
|
|
|
This application was generated using JHipster 9.1.0, you can find documentation and help at [https://www.jhipster.tech/documentation-archive/v9.1.0](https://www.jhipster.tech/documentation-archive/v9.1.0).
|
|
|
|
## Project Structure
|
|
|
|
Node is required for generation and recommended for development. `package.json` is always generated for a better development experience with prettier, commit hooks, scripts and so on.
|
|
|
|
In the project root, JHipster generates configuration files for tools like git, prettier, eslint, husky, and others that are well known and you can find references in the web.
|
|
|
|
`/src/*` structure follows default Java structure.
|
|
|
|
- `.yo-rc.json` - Yeoman configuration file
|
|
JHipster configuration is stored in this file at `generator-jhipster` key. You may find `generator-jhipster-*` for specific blueprints configuration.
|
|
- `.yo-resolve` (optional) - Yeoman conflict resolver
|
|
Allows to use a specific action when conflicts are found skipping prompts for files that matches a pattern. Each line should match `[pattern] [action]` with pattern been a [Minimatch](https://github.com/isaacs/minimatch#minimatch) pattern and action been one of skip (default if omitted) or force. Lines starting with `#` are considered comments and are ignored.
|
|
- `.jhipster/*.json` - JHipster entity configuration files
|
|
- `/src/main/docker` - Docker configurations for the application and services that the application depends on
|
|
|
|
## Database Configuration
|
|
|
|
### Development Database (H2 Console)
|
|
- **Profile**: `dev`
|
|
- **Database Type**: H2 (File-based, embedded)
|
|
- **JDBC URL**: `jdbc:h2:file:./build/h2db/db/sisvietnamvn`
|
|
- **Username**: `sisvietnamvn`
|
|
- **Password**: *(leave blank)*
|
|
- **Console Access**: [http://localhost:8080/h2-console](http://localhost:8080/h2-console) (requires app running in dev profile)
|
|
- **Config File**: [application-dev.yml](file:///d:/website_sisvietnam_moi/website_sisvietnam.vn/sisvietnamvn/src/main/resources/config/application-dev.yml)
|
|
|
|
### Production Database
|
|
- **Profile**: `prod`
|
|
- **Database Type**: Oracle Database
|
|
- **JDBC URL**: `jdbc:oracle:thin:@localhost:1521:xe`
|
|
- **Username**: `sisvietnamvn`
|
|
- **Config File**: [application-prod.yml](file:///d:/website_sisvietnam_moi/website_sisvietnam.vn/sisvietnamvn/src/main/resources/config/application-prod.yml)
|
|
|
|
### Schema Management
|
|
- **Tool**: Liquibase
|
|
- **Changelog Folder**: [src/main/resources/config/liquibase/](file:///d:/website_sisvietnam_moi/website_sisvietnam.vn/sisvietnamvn/src/main/resources/config/liquibase/)
|
|
|
|
## Development
|
|
|
|
To start your application in the dev profile, run:
|
|
|
|
```bash
|
|
./gradlew
|
|
```
|
|
|
|
For further instructions on how to develop with JHipster, have a look at [Using JHipster in development][].
|
|
|
|
## Building for production
|
|
|
|
### Packaging as jar
|
|
|
|
To build the final jar and optimize the sisvietnamvn application for production, run:
|
|
|
|
```bash
|
|
./gradlew -Pprod clean bootJar
|
|
```
|
|
|
|
To ensure everything worked, run:
|
|
|
|
```bash
|
|
java -jar build/libs/*.jar
|
|
```
|
|
|
|
Refer to [Using JHipster in production][] for more details.
|
|
|
|
### Packaging as war
|
|
|
|
To package your application as a war in order to deploy it to an application server, run:
|
|
|
|
```bash
|
|
./gradlew -Pprod -Pwar clean bootWar
|
|
```
|
|
|
|
### JHipster Control Center
|
|
|
|
JHipster Control Center can help you manage and control your application(s). You can start a local control center server (accessible on http://localhost:7419) with:
|
|
|
|
```bash
|
|
docker compose -f src/main/docker/jhipster-control-center.yml up
|
|
```
|
|
|
|
## Testing
|
|
|
|
### Spring Boot tests
|
|
|
|
To launch your application's tests, run:
|
|
|
|
```bash
|
|
./gradlew test integrationTest jacocoTestReport
|
|
```
|
|
|
|
## Others
|
|
|
|
### Code quality using Sonar
|
|
|
|
Sonar is used to analyse code quality. You can start a local Sonar server (accessible on http://localhost:9001) with:
|
|
|
|
```bash
|
|
docker compose -f src/main/docker/sonar.yml up -d
|
|
```
|
|
|
|
Note: we have turned off forced authentication redirect for UI in [src/main/docker/sonar.yml](src/main/docker/sonar.yml) for out of the box experience while trying out SonarQube, for real use cases turn it back on.
|
|
|
|
You can run a Sonar analysis with using the [sonar-scanner](https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner) or by using the gradle plugin.
|
|
|
|
Then, run a Sonar analysis:
|
|
|
|
```bash
|
|
./gradlew -Pprod clean check jacocoTestReport sonarqube -Dsonar.login=admin -Dsonar.password=admin
|
|
```
|
|
|
|
Additionally, Instead of passing `sonar.password` and `sonar.login` as CLI arguments, these parameters can be configured from [sonar-project.properties](sonar-project.properties) as shown below:
|
|
|
|
```bash
|
|
sonar.login=admin
|
|
sonar.password=admin
|
|
```
|
|
|
|
For more information, refer to the [Code quality page][].
|
|
|
|
### Docker Compose support
|
|
|
|
JHipster generates a number of Docker Compose configuration files in the [src/main/docker/](src/main/docker/) folder to launch required third party services.
|
|
|
|
For example, to start required services in Docker containers, run:
|
|
|
|
```bash
|
|
docker compose -f src/main/docker/services.yml up -d
|
|
```
|
|
|
|
To stop and remove the containers, run:
|
|
|
|
```bash
|
|
docker compose -f src/main/docker/services.yml down
|
|
```
|
|
|
|
[Spring Docker Compose Integration](https://docs.spring.io/spring-boot/reference/features/dev-services.html) is enabled by default. It's possible to disable it in `application.yml`:
|
|
|
|
```yaml
|
|
spring:
|
|
...
|
|
docker:
|
|
compose:
|
|
enabled: false
|
|
```
|
|
|
|
You can also fully dockerize your application and all the services that it depends on.
|
|
To achieve this, first build a Docker image of your app by running:
|
|
|
|
```bash
|
|
npm run java:docker
|
|
```
|
|
|
|
Or build an arm64 Docker image when using an arm64 processor OS, i.e., Apple Silicon chips (M\*), running:
|
|
|
|
```bash
|
|
npm run java:docker:arm64
|
|
```
|
|
|
|
Then run:
|
|
|
|
```bash
|
|
docker compose -f src/main/docker/app.yml up -d
|
|
```
|
|
|
|
For more information refer to [Docker and Docker-Compose](https://www.jhipster.tech/documentation-archive/v9.1.0/docker-compose/), this page also contains information on the Docker Compose sub-generator (`jhipster docker-compose`), which is able to generate Docker configurations for one or several JHipster applications.
|
|
|
|
## Continuous Integration (optional)
|
|
|
|
To configure CI for your project, run the ci-cd sub-generator (`jhipster ci-cd`), this will let you generate configuration files for a number of Continuous Integration systems. Consult the [Setting up Continuous Integration](https://www.jhipster.tech/documentation-archive/v9.1.0/setting-up-ci/) page for more information.
|
|
|
|
## References
|
|
|
|
- [JHipster Homepage and latest documentation](https://www.jhipster.tech/)
|
|
- [JHipster 9.1.0 archive](https://www.jhipster.tech/documentation-archive/v9.1.0)
|
|
- [Using JHipster in development](https://www.jhipster.tech/documentation-archive/v9.1.0/development/)
|
|
- [Using Docker and Docker-Compose](https://www.jhipster.tech/documentation-archive/v9.1.0/docker-compose)
|
|
- [Using JHipster in production](https://www.jhipster.tech/documentation-archive/v9.1.0/production/)
|
|
- [Running tests page](https://www.jhipster.tech/documentation-archive/v9.1.0/running-tests/)
|
|
- [Code quality page](https://www.jhipster.tech/documentation-archive/v9.1.0/code-quality/)
|
|
- [Setting up Continuous Integration](https://www.jhipster.tech/documentation-archive/v9.1.0/setting-up-ci/)
|
|
- [Node.js](https://nodejs.org/)
|
|
- [NPM](https://www.npmjs.com/)
|
|
|
|
## Deployment Guide (Ubuntu server + aaPanel + Executable JAR)
|
|
|
|
### 1. Build the JAR file (on Windows)
|
|
Spring Boot applications come with a built-in web server, meaning you can package your entire application into a single executable `.jar` file!
|
|
Run the following command on your Windows PC to build the production-ready `.jar` file:
|
|
```powershell
|
|
./gradlew -Pprod clean bootJar
|
|
```
|
|
Alternatively, you can use the built-in npm script:
|
|
```powershell
|
|
npm run java:jar:prod
|
|
```
|
|
The generated `.jar` file will be located at `build/libs/sisvietnamvn-1.0.3.jar`.
|
|
|
|
### 2. Deploy and Run the application (on Ubuntu Server)
|
|
|
|
You have two main options to run the application on Ubuntu: using **aaPanel** or using standard **systemd**.
|
|
|
|
#### Option A: Using aaPanel (Recommended)
|
|
If you are using aaPanel, it is highly recommended to use its built-in **Java Project** manager to easily run the JAR file.
|
|
|
|
1. **Install Java 21**: Make sure Java 21 is installed on your Ubuntu server via aaPanel.
|
|
2. **Upload the JAR**: Upload the `sisvietnamvn-1.0.3.jar` file to a folder on your server (e.g., `/www/wwwroot/sisvietnam.vn/`).
|
|
3. **Add Java Project**: In aaPanel, go to **Website** -> **Java Project** -> **Add Java project**.
|
|
4. **Configure Project**:
|
|
- **Project Type**: `Spring_boot`
|
|
- **Project jar**: Select the `sisvietnamvn-1.0.3.jar` file you just uploaded.
|
|
- **Project Port**: `8080` (or whichever port your app is configured to use).
|
|
- **Run user**: `www` (or `root`)
|
|
- Click **Submit**. aaPanel will automatically run your JAR file in the background!
|
|
|
|
#### Option B: Using systemd (Standard Ubuntu)
|
|
If you prefer managing the server manually via terminal, you can register the JAR as a `systemd` service so it runs continuously in the background and starts automatically on boot.
|
|
|
|
1. **Upload the JAR**: Upload the `sisvietnamvn-1.0.3.jar` file to your server (e.g., `/var/www/sisvietnam/sisvietnamvn.jar`).
|
|
2. **Create the Service File**:
|
|
```bash
|
|
sudo nano /etc/systemd/system/sisvietnam.service
|
|
```
|
|
3. **Add Configuration**: Paste the following, making sure the `ExecStart` path matches where you put the jar.
|
|
```ini
|
|
[Unit]
|
|
Description=SIS Vietnam Spring Boot Application
|
|
After=syslog.target network.target
|
|
|
|
[Service]
|
|
User=root
|
|
ExecStart=/usr/bin/java -jar /var/www/sisvietnam/sisvietnamvn.jar
|
|
SuccessExitStatus=143
|
|
Restart=always
|
|
RestartSec=10
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
```
|
|
4. **Start the Service**: Run the following commands to reload systemd, enable the service to start on boot, and start it now:
|
|
```bash
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable sisvietnam.service
|
|
sudo systemctl start sisvietnam.service
|
|
```
|
|
5. **Check Status & Logs**:
|
|
- To check if it's running: `sudo systemctl status sisvietnam.service`
|
|
- To view the live terminal output: `sudo journalctl -u sisvietnam.service -f`
|
|
|
|
### 3. Configure NGINX Reverse Proxy (aaPanel)
|
|
When you set up a Java Project in aaPanel, it can automatically map your domain and set up a reverse proxy. If you need to verify or set it up manually:
|
|
|
|
1. **Add Site**: Go to aaPanel -> Website -> Add site. Enter your domain (e.g., `sisvietnam.vn`) and select **Static** for the PHP version.
|
|
2. **Setup Reverse Proxy**: Click "Settings" for the site -> "Reverse proxy" -> "Add reverse proxy".
|
|
- **Proxy name**: `JavaProxy`
|
|
- **Target URL**: `http://127.0.0.1:8080`
|
|
- **Sent Domain**: `$host`
|
|
3. **Spring Boot Proxy Trust**: Ensure Spring Boot knows it is behind a proxy so it can read client IPs correctly. In `src/main/resources/config/application-prod.yml`, verify this exists:
|
|
```yaml
|
|
server:
|
|
forward-headers-strategy: framework
|
|
```
|
|
4. **SSL**: Use aaPanel's built-in SSL manager to apply Let's Encrypt certificates to your NGINX site. You don't need to configure SSL inside Spring Boot itself.
|
|
|
|
|
|
debug mode
|
|
|
|
.\gradlew.bat bootRun --debug-jvm
|
|
## Troubleshooting: Oracle DB ORA-01017 during Development
|
|
If you encounter an `ORA-01017: invalid credential or not authorized` error when starting the application using `bootRun`, ensure the following steps have been taken:
|
|
|
|
### 1. Database & User Creation (Oracle 23ai Free)
|
|
You need to create a dedicated Pluggable Database (PDB) and a user inside the Oracle Docker container.
|
|
1. Connect to your LXC container host (e.g. `192.168.1.15`).
|
|
2. Open a `sqlplus` session inside the Oracle container:
|
|
```bash
|
|
docker exec -it sisvietnam-oracle-sisvietnam-oracle-1 sqlplus sys/Oracle123 as sysdba
|
|
```
|
|
3. Run the following SQL to create the PDB and User:
|
|
```sql
|
|
CREATE PLUGGABLE DATABASE sisvietnam ADMIN USER pdbadmin IDENTIFIED BY Oracle123 FILE_NAME_CONVERT = ('/opt/oracle/oradata/FREE/pdbseed/', '/opt/oracle/oradata/FREE/sisvietnam/');
|
|
ALTER PLUGGABLE DATABASE sisvietnam OPEN;
|
|
ALTER PLUGGABLE DATABASE sisvietnam SAVE STATE;
|
|
ALTER SESSION SET CONTAINER = sisvietnam;
|
|
CREATE USER sisvietnam IDENTIFIED BY "sisvietnam";
|
|
GRANT DBA TO sisvietnam;
|
|
GRANT ALL PRIVILEGES TO sisvietnam;
|
|
```
|
|
|
|
### 2. Configure Spring Boot
|
|
Update your `application-dev.yml` to point to the newly created `sisvietnam` PDB:
|
|
```yaml
|
|
spring:
|
|
datasource:
|
|
url: jdbc:oracle:thin:@192.168.1.15:1521/sisvietnam
|
|
username: sisvietnam
|
|
password: "sisvietnam"
|
|
```
|
|
|
|
### 3. Check for Overriding Profiles (Important!)
|
|
By default, the JHipster setup might enable the `secret-samples` profile. This profile aggressively overrides the database username and blanks out the password. Check `src/main/resources/config/application-secret-samples.yml`. If you encounter an `ORA-01017`, ensure that the `dev` section in the `secret-samples` profile correctly mirrors your real credentials:
|
|
```yaml
|
|
spring:
|
|
config:
|
|
activate:
|
|
on-profile: dev
|
|
datasource:
|
|
username: sisvietnam
|
|
password: sisvietnam
|
|
```
|