How to build an Angular2 type script with spring boot back end in STS - spring-boot

I am learning angular 2 currently and trying to hosted in springboot java application.
I created a separate project using angular cli , then I created spring starter project with web only.
Next I imported the angular cli project inside /src/main/resources/static directory.
when I opened the browser , I was not able to see the basic index.html.
Then I removed all the imported files and imported only the content of the directory , which is the resulting compiled ES5 java script after transpiling the type script files in directory, this time it worked.
My questions are:-
1) What is the best practice , to use the GUI under /src/main/statis or create /src/main/public or /src/main/webapp ?
2) Does spring understand only js and not ts ( java script and not type script)?
3) Do I need a maven plugin for typescript and if so how to tell maven bundle the compiled js with the spring war while excluding the rest directories and files
4) How to include the testing unit / e2e with maven build
I searched for step by step guide for ANgular 2 and spring boot but could not find one. It would be helpful to many if some guide like this exist.
Many thanks for your support guys.

1) What is the best practice , to use the GUI under /src/main/statis or create /src/main/public or /src/main/webapp ?
Since typescript compiles to JavaScript I strongly recommend using GULP. I have my source files under src/client and I build with gulp to add the files to src/main/public
I believe either public or webapp works and there's not a huge difference.
2) Does spring understand only js and not ts ( java script and not type script)?
The newer version of STS has support for typescript, but I prefer to use visual studio code when viewing typescript files as there is better support.
3) Do I need a maven plugin for typescript and if so how to tell maven bundle the compiled js with the spring war while excluding the rest directories and files
If you use gulp, the typescript is compiled to js and added to the src/main/public directory where your springboot app sees the files when running with maven.
4) How to include the testing unit / e2e with maven build
I searched for step by step guide for ANgular 2 and spring boot but could not find one. It would be helpful to many if some guide like this exist.
Many thanks for your support guys.
I recommend using an angular seed or starter, this seems like the most up to date one that I've found:
https://github.com/antonybudianto/angular2-starter
This uses gradle, but is spring boot and angular 2:
https://github.com/borysn/spring-boot-angular2

I shared a project on github that integrates Angular 2 With spring boot. Just need to follow the step on readme or check commit history. You can access here Angular 2 with spring boot

Related

Maven Generate OpenAPI JSON for SpringBoot REST Controllers

Is there a Maven plugin which can generate an openapi.json file at build time for my SpringBoot RestControllers?
If not a Maven plugin, is there another simple package to generate the file at build time?
I only want the openapi.json file, I don't want Swagger UIs auto-integrated, etc.
I was able to get this working with SpringDoc.
I couldn't find a project which showed exactly my use-case (without all the swagger ui stuff), so I created an example project on GitHub for others to use as reference: springdoc-maven-plugin-demo
You can use Spring-doc which support OpenAPI 3
Look at the demos

Spring Roo web mvc setup generates error globalsearch.java class doesn't exists or has been deleted

I am quite new to Spring, now trying out Roo. I am following documentation from http://docs.spring.io/spring-roo/docs/2.0.0.M1/reference/html/
I was able to create the entity classes and fields, perform tests as well. Now when I run
roo> web mvc setup
it creates a few files in \config, \validatin, \html\converter but then produces undo create ... for the same files & folders. At the end it says
ERROR: GlobalSearch.java class doesn't exists or has been deleted.
I am running Windows 10 64 bit, STS 3.8 Release, Roo 2.0.0.M2, Maven 3.3.9, Jdk 1.8
Googling this as well as searching in StackOverflow gave just one slightly relevant result without resolution Spring Roo: 'web mvc setup' fails with 'display name required'.
In fact I have been facing many issues, each step of the way and googling my way through, so it has been a very painful experience so far, so any help is greatly appreciated.
I was using a separately downloaded roo (v 2)for this.
Alternatively I used STS and added roo (v 1.3.1RC1) extension thru Help>Dashboard and opened roo console in STS (Window>Show view>Roo shell), was able to run the commands for mvc web setup and mvc web all --package ~.web and generate required files!
But don't know why the separate roo console wouldn't work.
Thanks for all who viewed and tried to help.
First you need to create DAO layer:
repository jpa --all --package ~.repository
This will generate GlobalSearch.java in repository package.

Spring Jars to download

I am using below link for downloading spring jars.
http://repo.spring.io/release/org/springframework/spring/4.1.4.RELEASE/
I am confused with so many links.
Which link should i use to download the jar?
I am using a Windows machine and create a project directly through New Java Project.
Please refer this url http://repo.spring.io/release/org/springframework/spring/ and Choose the which version Spring Jars you want.
Choose the spring-framework-X.X.X.RELEASE-dist.zip
You should be using this link to download spring jars. Other links in there are for checksum or documentation.
Important points to understand in all the spring related repo is that it contains 3 zip files .
spring-framework-{version}-dist.zip : contains all the spring
related jars.
spring-framework-{verison}-docs.zip : contains all the standard documents in HTML format for spring and related java api documents. It is similar to Oracle API Documentation.
**Note : Inside all the folders you will find and index.html file. U can consume it typing the folder path till index.html in web browser.
spring-framework-{version}-schema.zip*: contains all the spring modules based standard xsd for xml based spring development.
I hit the same issue and I followed Brian Clozel advice above.
Create a new Maven project in eclipse.
Edit the pom.xml and add the Spring dependencies as follows -
org.springframework
spring-core
5.0.6.RELEASE
When you build the project in eclipse,it hits the maven repo and downloads the requisite spring jars for you. The indirect dependencies should also be downloaded automatically.
Hope this helps.
Step 1) Place this URL in browser
https://repo.spring.io/ui/native/release/org/springframework/spring/
Step 2) Scroll down & select latest version. Example : 5.3.9/
Step 3) Click on the file similar to "spring-5.3.9-dist.zip" to download
Step 4) Hence JAR files of latest spring is downloaded in zip format.

Using Google App Engine modules for multi-thread backend update of a Cloud endpoints project

I'm building "read-only" webservice (Google Cloud Endpoints as backend for an Android App) so I created a project using maven:
mvn archetype:generate -Dappengine-version=1.9.10 -Dfilter=com.google.appengine.archetypes:
and selecting archetype hello-endpoints-archetype to have some sample code to work on.
This works well and my app is correctly calling the service as expected (and the service is correctly supplying the data in return).
Now I have to implement an "update" service to periodically (4 to 6 times a dya) update the data supplied to the app. So I added a servlet to my project to be called by cron. Trouble is: one of the library used during this update uses multi-threads which cause an AccessControlException to be thrown because apparently multi-thread is only allowed in backend modules...
But after having read dozens of pages on google app engine, I still don't know how to "break" my application into modules so that particular servlet would be run as a backend module while the already existing servlet keep working as they do. So far, all I got was that I should use an EAR application composed of several WAR modules, but I don't even know if my current application is an EAR or not...
I'm using Eclipse Luna, maven 3.2.1 (embeded with Eclipse), google app engine 1.9.10, writing in Java
Could anyone please help me by explaining the directory structure and/or configuration files I have to look at, modify and/or add?
Thanks for any help provided!
You can find an example of multi-modules project here.
However, note that even in backend modules the threading is limited to 50 threads, as stated here.

Simple Spring batch project in spring source tools suits using maven

I m very new in spring batch project.I m trying to create a project in spring batch framework but i don't know how to create a project in spring batch framework,so please help me regarding my problem.Firstly just tell me that how i create a simple "hello world" program using Simple Spring Batch Project in spring source tools suits using maven.
Thanks in advance.
From the documentation, it looks like there is no real maven archetypes to build the skeleton of a spring batch projet.
The documentation recommends anyway to copy samples and examples from their website to start from.
http://static.springsource.org/spring-batch/getting-started.html
Spring Batch is not trivial for the first time, then I recommend you to copy this code:
https://github.com/spring-projects/spring-batch/tree/master/spring-batch-samples
Then, using Eclipse open this (Maven project) and compile (mvn clean install)
Last thing (if all works ok) just run the main method, usually o Scheduler task.

Resources