I am working on a project that needs to be refactored in order to achieve decoupled modules.
I need to us an Adapter to decide which module to route to depending on some config.
+===========+
| Front-end |
+===========+
| |
+==================+ +==================+
| RESTful Service1 | | RESTful Service2 |
+==================+ +==================+
| |
+=========================+ +=========+
| Adapter | --- | Config |
+=========================+ +=========+
| | |
+=========+ +=========+ +=========+
| Module1 | | Module2 | | Module3 |
+=========+ +=========+ +=========+
I have a Java application, and want to package the modules in JARS using Maven.
RESTful Service1 will either talk to Module1 or Module2 while RESTful Service2 will always talk to Module3. I need to establish which is the nest way to package these modules.
RESTful Service1 will be in it's own Jar while Module1 and Module2 will have their own Jars too.
Question
Seeing that RESTful Service2 will always talk toModule3 only, should they be in the same Jar? Or should I separate them into two seperate Jars too?
Thanks
Because RS2 when deployed always needs to work with M3, putting them in the same jar offers one benefit: we won’t forget M3 when deploying RS2. But the downside is that it is difficult to reuse and deploy M3 to another system which does not require RS2.
I think the benefit above is little. Often, when deploying a system you should have a document or checklist. Even if some component was forgotten, chance is that you could detect and fix it quickly.
So the better option is to seperate RS2 and M3 into two jars.
Related
In our Spring boot Java project we are having flyway migration scripts. Below is our project structure,
Project
|
|
+-- src
| |
| +-- resources
|
+-- db.migration
|
+--V1_0_db_script.sql (scheme_one)
+-- test
| |
| +-- resources
| |
| +-- db
| |
| +-- data-test
| | |
| | +--V1_0_test_db_script.sql (scheme_one)
| +-- data-sql
| | |
| | +--V1_0_sql_db_script.sql (scheme_second)
| |
+-- application-test.yml
Now, here is my application-test.yml structure.
Flyway :
enabled: true
schemas: scheme_one
locations:
- classpath: /db/data-sql
- classpath: /db/migration
- classpath: /db/data-test
Now, what is needed here is that while running test cases, it should execute data-sql directory first it means V1_0_sql_db_script.sql should execute first then db.migration and then data-test directory. But its not executing in the order which defined in location (My assumption is from top to bottom, even I tried bottom to top).
Now what's happening, it always first executing db.migration which is located under main src package. But I want to execute data-sql directory scripts first anyhow while test cases are started to run as there are some queries which is needed for other scripts. One more thing, there are actually two different schemes used. I have defined in brackets.
Kindly suggest if flyway have any property to define order or any other feedback will be appreciated.
I have a monorepo with the following structure:
app
|lib
| -moduleA
| |-pom.xml
| -moduleB
| |-pom.xml
|services
| |-foo
| |-pom.xml
| |bar
| |-pom.xml
| |gamma
| |-pom.xml
My end goal here is to deploy the application's war files to aws via GitHub actions. I am able to deploy individual services whenever there are changes in them, with the command mvn clean install -Dmaven.clean.failOnError=false -f services/foo/pom.xml.
However, I am not sure how to update the services whenever a module it depends on is modified. For eg., foo and gamma depend on moduleA. Whenever moduleA is modified, I would like to build war files only for foo and gamma and exclude bar since there are no changes for it. Pretty new to java, any ideas how to achieve this? TIA
Was able to find a flag that updates the dependencies of the module
--also-make-dependents
I want to exclude a specific file from the base jar while running my project (which will use the base jar as dependency)
Base project structure looks like:-
baselib
|
|----src
| |
| |--some packages
| |
| |--resources
| | -- somefile.xml
|
|---target
Another project called "mycustomproject" will have "baselib" as dependency jar in pom.xml
My question i,s how to debug/run (Debug As/Run As-> Spring Boot App) the "mycustomproject" by excluding "somefile.xml" alone. I cannot remove this file in "baselib" since some one is using it.
Could someone share some inputs here?
I'm trying to configure Camunda automatic resource deployment for a multimodule project. What I want to archive is that for the following project structure:
\---learnCamunda
| pom.xml
+---application
| | pom.xml
| +---src
| \---main
| +---java
| | \---com
| | \---camunda
| | \---learnCamunda
| | | LearnCamundaApplication.java
| | \---configuration
| | CustomOracleDialect.java
| | FlywayConfiguration.java
| | H2ConsoleConfiguration.java
| \---resources
| | application.properties
| |
| \---processes
| loanRequest.bpmn
+---contract-management
| pom.xml
\---src
\---main
+---java
| \---com
| \---camunda
| \---learnCamunda
| +---dto
| +---dts
| +---entity
| \---enums
\---resources
\---processes
DUMMY_PROCESS.bpmn
where application and contract management are modules of learnCamunda project, I want my application.properties to provide classpath for Camunda resource scan to pickup both loanRequest.bpmn and DUMMY_PROCESS.bpmn. Is that possible via application.properties in application module? (The application module has dependency on contract-management module)
If it is possible then which camunda property -- should I set it and to what?
I have already tried different combinations of deployment-resource-pattern but non of them worked.
EDIT:
One thing i noticed is that PathMatchingResourcePatternResolver.findAllClassPathResources loads all resources from target, my compiled model is in target.classes.processes and classpath resource from resolver is target.classes so it seems it's not done recursively, but im having hard time to confirm this
You are correct to be looking at the deployment-resource-pattern property as the place to start. By default, it will include classpath*:**/*.bpmn so your file should be loaded.
That suggests the problem is either the value of deployment-resource-pattern has been changed or the contract-management jar is not on the classpath.
I suggest you try debugging the app to check the value of camunda.deployment-resource-pattern. Then have a look at the build process and make sure your application depends on contract-management, its the same version and the parent pom is building both of them.
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:
CustomAuthFilter.java for Security Filter Chain
CustomUserDetailsService.java for AuthenticationManager
CustomEntryPoint.java for handle exceptions
CustomJwtService.java for managing jwt tokens
CustomAuthController.java for rest endpoints like /login, /logout, /create-user, /reset-password
Can you tell me where store this classes? I have 2 ideas:
Create security folder and put it here together
Split files into existing folders like that: CustomAuthFilter.java -> config, CustomUserDetailsService.java -> service, CustomEntryPoint.java -> config, CustomJwtService.java -> service, CustomAuthController.java -> web
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