Angular2 application with springboot using maven - spring

I am new to Springframework. I created a Springboot application and expose rest services. Now I want to consume my rest services in angular2. I am not sure how to create folder structure for my application. Should I create angular2 app in src/main/resources folder using angular cli? or as I am exposing rest services so should I create a separate angular project and consume the services? But if user this approach it will run on two different ports on localhost and I get CrosOrigin error.
In production I will deploy the application on same server. It will be a one website.
One more point I am using Maven and STS tool suit to create springboot application.

For a Spring-Boot novice using AngularJS you might be checking out JHipster (which actually is a combination of these two projects), which might serve you with some best practices.
Currently based on AngularJS 1 - it's not Angular2 yet - however they're busy porting it to version 2 (see progress, see this branch).
Alternatively there's also a guide on how to create a standalone Spring-Boot application with AngularJS (1).

I find some sample code but even in Springboot application you have to run spring and angular application on two different ports on local host. So the best way to solve the problem is to create two application expose services in spring boot and use in angular client side. While running on local use enable CORS.
Another way is to use JHipster. They recently release JHipster 4 which support angular 2.

Related

Is it ok to connect two camunda instances to the same database?

We are developing a spring boot application(generated with jhipster, with oauth) and we want to use camunda.
The camunda spring boot starter(with the process engine only) worked, however the we had problems with the other two starters(rest, web) in our current setup(although they work with a simple project like in the camunda examples).
We actually prefer using the embedded process engine like this, however, we would like the operational advantages of the camunda webapps.
The preferred solution we thought about was to connect to the same database another process engine(camunda standalone or springboot app with camunda web starter). This seems to be working in our tests.
The other solution would be to use camunda standalone and communicate via rest api, and subscribe to topics for service tasks.
Do you see any problems with the preferred solution?
Yes, it's perfectly fine running two engines against same database. Just make sure to set camunda.bpm.job-execution.enabled=false in the other instance(if you don't want it to pick up and execute jobs)

How to connect Java spring application with Angular 4 application

I made a Spring rest application and Angular 4 application and I want to use Spring rest Api's in my Angular 4 application. Simple CRUD application. which could be the best format of communication between these application
You can take a look at this Spring Guide.
It is for AngularJS, but the server side code is absolutely the same in case of Angular 2,3,4 as well.
If possible try not to club angular and spring-boot together, sure you can do this using webjars or similar libraries, but try not doing it. Spin off the angular app as a separate application (you can serve this Angular app either using nginx or nodeJs) and then route all the API calls through the Angular App to your Spring boot application. Now your spring boot application will be just a ( micro ) service which will have to deal only with the data, not the presentation (markup / style etc).

How enable Angular Universal with a Java/Spring backend?

I have an app, where backend implements on Spring using Spring Boot and front-end side use Angular2. Can somebody help me and explain how to integrate Universal using Java becken. Or show me a good example how I can do that.
how to integrate Universal using Java beckend?
You cannot do that directly as universal needs a different server side technology -nodejs
But you have a another (better) solution
Spin off a separate nodejs app for the angular and universal then route all the API calls through the nodeJs to your Spring boot application. Now your spring boot application will be just a (micro)service which will only deal with the data, not the presentation (markup/style etc)

UI application in Pivotal Cloud Foundry

I have a UI application built using Angular , Bootstrap and HTML5 which interacts with number of backend services. In order to deploy this application in PCF , should this be converted to a Spring Boot app? Or is there a way to use any of available buildpacks to deploy this UI app in PCF?
In case there is no need to deploy backend services, I would go with the cloudfoundry static buildpack.
http://docs.cloudfoundry.org/buildpacks/staticfile/index.html
Otherwise you will need to decide how you are going to deploy the backend services for this application. There are a number of buildpacks available that could be used for deploying the backend services and delivering the frontend content within the same app (one of them being, as you mentioned the java buildpack that can be used to deploy a spring boot app). Here is a list of available buildpacks:
http://docs.cloudfoundry.org/buildpacks/
Its not needed to convert your application to spring boot, but doing so will definitely make life easier for you, trust me. Once u convert ur app to a spring boot right, you can remote debug ur application by jst running ur app as a spring boot app.

How to deploy a spring integration component?

I've developed a spring integration component that is to sit on a server and process messages coming in over an inbound RMI channel do some processing/filtering and then send out some messages over a different RMI channel.
Currently, for testing, I've been running it using a Main class that just loads the context, which sets up the inbound RMI gateway and it's working fine. But I don't think that this is appropriate for a production environment.
What is the best way to deploy this type of project to a server?
If I were working in a .Net I'd be deploying this type of application as a windows service, is that what I should be doing here?
The application that is sending me data is hosted in Tomcat, would it be a good idea to also run this application within the same Tomcat container (Current requirements are for both components to be on the same machine this may change)? And if so how?
I'm currently looking into Spring Boot, am I on the right path?
I think the best would be Spring Boot, as it's made to easily allow running different types of applications. Also, you don't need Tomcat if you can run the same component with a simple Main and not using UI. Spring Boot, also, has a sample using Spring Integration here, so you should be up and running in no time.

Resources