To start mongo database
- http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-debugsymbols-4.0.2.zip
- mongod --dbpath=E:\mongodb-win32-x86_64-2008plus-ssl-4.0.2/mydb/
Angular routing with Springboot thymeleaf
- Create a 404.html in templates/error folder
<html> <meta http-equiv="refresh" content="0;url=/" /> </html>
- Create IndexController as following to register / path to serve index.html
@Controller public class IndexController { @RequestMapping(value = {"/"}) public String index() { return "index"; } }
Start development server (angular)
If --aot=true is not provided then lazy routing wont work
ng serve --aot=true
Handy tips:
- Add HttpClientModule in imports section to works with http
- ngNativeValidate helps to prevent form submission if required field is not filled, usage e.g.
<form (submit)="onSave()" name="addNewBook" ngNativeValidate>
- To use material date with locale (ar-SA)
- install npm i --save @angular/material-moment-adapter
- intsall npm i --save moment
// `MomentDateAdapter` and `MAT_MOMENT_DATE_FORMATS` can be automatically provided by importing
// `MatMomentDateModule` in your applications root module. We provide it at the component level
// here, due to limitations of our example generation script.
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
{provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS},
]
Deploy angular application in springboot application
To remove directory while building application: npm install rimraf -g
To create directory while building application: npm install mkdirp -g
To copy application from dist into springboot static folder: npm i copyfiles -g
Sample configuration : e.g. package.json
"build": "ng build --prod --aot=true --base-href=/ui/ --deploy-url=/ui/", "postbuild": "npm run deploy", "predeploy": "rimraf ../resources/static/ui && mkdirp ../resources/static/ui", "deploy": "copyfiles --up 2 dist/**/*.* ../resources/static/ui && copyfiles --up 2 dist/**/index.html ../resources/templates/ui/",
spring security
Disable spring security while development
Add /** in last pathMatchers to bypass security http.authorizeExchange().pathMatchers("/login","/signup","/api/users/login","/ui/assets/","/webjars/").permitAll()
Clean npm cache
npm cache clean --force