Create a maven project with in another java project - java

As part of small project i need to provide a micro service to create/generate maven based java projects (something similar to Spring Initializr but a basic one ).
Since my aim is to just get a maven project, i came across Maven Invoker which looks like would serve my purpose. The question that i have is, if i have to host on heroku or aws/gce would it work? I ask because they look like need maven installed on the host where it is deployed , or am i wrong. Any help would be appreciated.

Related

How to add swagger-input to my spring boot application

I used to work in a company where we use this swagger-input file and this is where we declare all the endpoints and all of the class files will be automatically generated once we built our maven project.
I always wanted to know how to set this up by myself and I haven't figured it out even if my task was to create a new microservice. We always used a custom archetype when generating maven projects and I assumed that is where it was all setup(ed?).
I've been searching for tutorials on how to do this but it would really be of great help if someone could point me in the right direction for this. Thank you for your time.

How do I divide my code into two applications?

I have a few java classes, holding my application's logic. Now I want to create two applications, one will be a SpringBoot web application and another one will be a desktop application. Both of them will use logic, that I already wrote.
I see only one way to do it: compiling logic classes into a .jar file and then putting it as a library into two Idea projects. But if I update any of this code, I will have to recompile it into jar and then replace an old jar with a new one in both projects.
Is there another, more simple way two divide my code into two projects?
What should I do with Git/GitHub?
P.S.
My project is in java, I use Intellij IDEA, GitHub.
Multi-module project
As commented, you need a multi-module project. The content for each module is compiled separately, producing separate JAR files.
IntelliJ supports multi-module projects.
I recommend using a Java build management tool to assist. Apache Maven is one such tool that supports multiple modules.
The word “module” used here in this context should not be confused for the Java Platform Module System. You may or may not choose to use Java modules in your project modules’ code.
I suggest rest web service interface to export the logic data..
SpringBoot web application can consume the rest services
and the other a desktop application can consume the rest services
ONE REST SERVICE LAYER
--------------------------------------
| |
Desktop app, SpringBoot web application
this way to don't duplicate your code and bugs twice.

How correctly make project structure in IntelliJ IDEA for Spring Boot microservices?

I used to work with Monolithic architecture and I don't have experience with Microservices. I need to create project with some modules (microservices).
auth
messages
I use IntelliJ IDEA for my project.
Can you explain me what is the best practice for microservices project structure in this IDE?
Should I use Maven or it is better to add IntelliJ IDEA project modules?
There are no right or wrong answer but in a monolith, you will probably end up with a structure like this (Domain Driven - Profile Domain, BankAccountDomain):
main
profile
model
Profile.java
ProfileRequest.java
ProfileResponse.java
ProfileController.java
ProfileService.java
ProfileRepository.java
bankaccount
model
BankAccount.java
BankAccountRequest.java
BankAccountResponse.java
BankAccountController.java
BankAccountService.java
BankAccountRepository.java
test
What you can do if you go to the extreme of microservice have each domain as a seperate microservice
You can use grade or maven to have different projects (microservice) within the same repo if thats what you are looking for.
https://docs.gradle.org/current/userguide/multi_project_builds.html

How set Flex server location for BlazeDS maven build

As a first step getting a Hello World Flex-to-Java application to compile and run I followed:
http://jatin4rise.wordpress.com/2011/04/03/configuration-eclipse-for-blazeds/
and it ran successfully. However now I wish to automate the build in Maven. Does anyone know how to specify the Flex Server location in the pom.xml?
Certainly a bit off topic, but you will find a good Flex/Maven integration together with GraniteDS. See documentation here (the "contextRoot" node in the pom.xml is what you are looking for). And you would also be able, among other things, to automate ActionScript3 beans generation (based on your Java entities/beans) with the same tool, see here.

Extending/Inheriting Tomcat Projects

We are developing webapps with Eclipse + Tomcat plugin. We recently started a new app which will run on Facebook and StudiVZ (FB competitor in Germany). Since the functionality of the app will be 95% the same we split the code into separate Eclipse projects (app-core, app-facebook, app-vz). The -core project is source-linked into the -facebook and -vz projects in Eclipse. We are also using Hudson for CI and made ant scripts that import the code from the -core project before building. So basically we tried to inherit on a project level.
The described method has some flaws:
Versioning is complicated
The -core project does not run standalone, which makes automatic testing partly impossible
We need to modify some models where the -core projects classes depend on
Other problems that make me think this is not the best solution
Does anyone have suggestions for a better solution?
There are a wealth of build tools available for Java that address dependency management and versioning specifically. Many of these integrate with Hudson and Eclipse.
I'd suggest looking at Maven and how it does dependency management as a good starting point. Even if you don't use Maven itself, many of the solutions out there build on Maven's dependency management mechanism. Something like Apache Ivy allows you to use maven dependency management, but still use your own custom Ant scripts; whereas something like Gradle is wholesale replacement.
You should be able to split your project into 3 or more parts and then establish dependencies via Java Build Path. You need to clean up the dependencies between the projects. If you need to configure your core components depending on whether it is a -facebook or a -vz project, you might need to separate configuration, maybe even use Spring or similar dependency injection framework.
When trying to introduce reuse into web-based Java projects, usually the problems arise in the UI code. Not many frameworks were built with this approach in mind.
I don't use/hate Eclipse[1], but can point to how we deal with a similar problem.
We use Maven with IntelliJ. In particular, both of these support modules which have defined internal dependencies. In your case it could be -fb and -vz modules depending on core, or you can split core into smaller parts (such as DAO, business logic, etc.).
When compiling, deliverables of "upper" modules would be used to build "lower" modules.
Let's go over points/flaws you have raised:
versioning is no longer a problem as everything sits under the same root of Subversion/GIT/VCS of your choice
Why is that a problem? Certainly this shouldn't be an issue for unit tests as how I understand TDD, these should not require complex environments. For automated tests, you would have to test the core API (as this is the interface between core and everything else, right?) hence this shouldn't require any fronted stuff?
you need to explain your other points to tell why you don't like it
It is against Geneva convention to ask a developer to use anything other than IDE of his/her choice.

Categories