local-remote debugging

* springboot pathvariable
main
Yik Teng Hie 5 years ago
parent b15ad4ba1d
commit 175ae97e4b

@ -0,0 +1,17 @@
# URL Path Variable Matching
* [Reference](https://www.baeldung.com/spring-5-mvc-url-matching)
| Pattern | Pattern String | Example | Matches | Remark |
| --------------- | ----------------------- | ------------------ | -------------------- | --------------------------- |
| {*foo} | /spring/{*id} | /spring/bb/tutor | /bb/tutor | |
| | | /spring/bb | /bb | |
| {*filepaths} | /files/{*filepaths} | /files/hello.txt | content of hello.txt | RouterFunctions.resources() |
| ? | /spring/t?st | /spring/test | | |
| * | /spring/*Id | /spring/TutorId | | |
| ** | /spring/** | /spring/xx/yy/xx | | |
| {params:[a-z]+} | /spring/{parama:[a-z]+} | /spring/parama=abc | abc | |
| {var1}_{var2} | /spring/{var1}_{var2} | /spring/aa_bb | aa,bb | |

@ -0,0 +1,104 @@
# Local Debugging Setup (Advance)
* IntelliJ IDEAS
* To bypass Spring Security to troubleshoot resource module independently, use this annotation
* remove `@EnableResourceServer`
* add exclusion `exclude={SecurityAutoConfiguration.class}`
```java
@SpringBootApplication(exclude={SecurityAutoConfiguration.class})
@RestController
//@EnableResourceServer
//@EnableScheduling
public class ResourceApplication {
...
}
```
* Setup debugger environment
* for remote db.
* Note : For `authserver`, not able to launch if remote db is Read-Only replica as the code will execute `schema.sql` against `uaa` table, which required write access
```text
DATABASE_SERVER_HOST=127.0.0.1;DATABASE=razerpay-malaysia-product;DATABASE_SERVER_USERNAME=tenghieyik;DATABASE_SERVER_PASSWORD=Razer*3ngF0RlIF32
```
* for local db (according to your local db setup)
```text
DATABASE_SERVER_HOST=127.0.0.1;DATABASE=razerpay-malaysia-product;DATABASE_SERVER_USERNAME=razerpay;DATABASE_SERVER_PASSWORD=razerpay-singapore
```
* Happy debugging !!!!
## Remote DB connection via tunnel (Malaysia)
* SSH tunnel setup at local computer
* Connect to Malaysia VPN
* Setup SSH Tunnel to an authorised EC2 for connecting to Malaysia sql sb.
```shell
$ ssh -L 3306:rr-zf81fzm6ija52q623.mysql.kualalumpur.rds.aliyuncs.com:3306 tenghieyik@172.22.4.252
```
* Test tunnel setup connection using `MySQL Workbench` to connect `localhost:3306`
* Setup IntelliJ setting to connect DB via `localhost:3306`
### For docker container setup
* Connect remote db from docker container via docker host SSH tunnel
* SSH tunnel
```shell
$ ssh -L host.docker.internal:3306:rr-zf81fzm6ija52q623.mysql.kualalumpur.rds.aliyuncs.com:3306 tenghieyik@172.22.4.252
// grab the host.docker.internal IP Address
$ ping host.docker.internal
Pinging host.docker.internal [192.168.0.132] with 32 bytes of data:
Reply from 192.168.0.132: bytes=32 time<1ms TTL=128
Reply from 192.168.0.132: bytes=32 time<1ms TTL=128
...
```
* `docker-compose.yml`
```yml
version: '2.1'
services:
resource:
image: registry-intl.ap-southeast-3.aliyuncs.com/razerpay-report-malaysia/resource:latest
# restart: always
mem_limit: 2048m
mem_reservation: 1024m
ports:
- "9000:9000"
environment:
- JAVA_TOOL_OPTIONS=-Xmx1024M
- DATABASE_SERVER_HOST=192.168.0.132
- DATABASE_SERVER_USERNAME=tenghieyik
- DATABASE_SERVER_PASSWORD=Razer*3ngF0RlIF32
- DATABASE=razerpay-malaysia-product
- MAIL_SERVER_USERNAME=
- MAIL_SERVER_PASSWORD=
logging:
options:
max-size: "50m"
```
*
Loading…
Cancel
Save