I am learning Spring boot and its modules, but I want avoid to learning bad practices. So can you tell me what project structure is usually using for that?
I am using this structure:
com
+- example
+- myproject
+- Application.java
|
+- config
| +- CustomSecurityConfig.java (extends WebSecurityConfigurerAdapter)
|
+- domain
| +- Customer.java
|
+- repository
| +- CustomerRepository.java
|
+- service
| +- CustomerService.java
|
+- web
+- CustomerController.java
Now I need implement JWT Authentication, so I have theese new classes:
Can you tell me where store this classes? I have 2 ideas:
Can yo give me some advice pls? Thank.
This is code organization problem and independent of spring boot.
Go by business sense/ functionality of the module than the technical sense of the module. Functionality sense helps to understand the code easily if you are looking after a while.
+Application.java
+security/
+-CustomAuth
+-CustomJwtSevice
if functionality is scatters in multiple files then keep them in subfolder like 'security' in above.
+Application.java
+security/
+-auth/
+--token/
+---JWTtokenGenerator.java
+---JWTutil.java
+--configuration/
+---SecurityConfig
+---...
+--customer/
+---customerservice.java
+---customerrepo.java
The above pattern works by dividing a module, into sub-module and sub-module to their sub-modules.. so on
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With