Repository: jhipster/generator-jhipster
Pull request #6805 (2017-12-04 22:05:50)

Use Pageable in many-to-many relationship
- Please make sure the below checklist is followed for Pull Requests.

- [x] [Travis tests](https://travis-ci.org/jhipster/generator-jhipster/pull_requests) are green
- [x] Tests are added where necessary
- [x] Documentation is added/updated where necessary
- [x] Coding Rules & Commit Guidelines as per our [CONTRIBUTING.md document](https://github.com/jhipster/generator-jhipster/blob/master/CONTRIBUTING.md) are followed

Fix for this: https://github.com/jhipster/generator-jhipster/issues/6791

deepu105: @ramzimaalej please let us know when its complete
ramzimaalej: sure @deepu105, sorry I have been quite busy lately.
ramzimaalej: @deepu105 @jdubois Before I take this further, I would like to have your opinion regarding the web layer. 

Currently, I have overloaded findAllWithEagerRelationships to take Pageable. However, for the web, I don't think the default behavior should be loading eager relationships. So, I would leave it to the developer to decide to use this method or not. what do you think?
jdubois: By default the user could load a Pageable with the default pagination size - then it's up to the developer to either increase the pagination size at the Spring Data level, or request for more entities in his REST request

Patch:
diff --git a/generators/client/files-angular.js b/generators/client/files-angular.js
index c992243834..359922b569 100644
--- a/generators/client/files-angular.js
+++ b/generators/client/files-angular.js
@@ -260,7 +260,7 @@ const files = {
                 { file: 'account/social/_social-register.component.html', method: 'processHtml' },
                 { file: 'shared/social/_social.component.ts', method: 'processJs' },
                 { file: 'shared/social/_social.component.html', method: 'processHtml' },
-                'shared/social/_social.service.ts'
+                'core/social/_social.service.ts'
             ]
         },
         {
@@ -338,8 +338,8 @@ const files = {
                 { file: 'admin/tracker/_tracker.route.ts', method: 'processJs' },
                 { file: 'admin/tracker/_tracker.component.ts', method: 'processJs' },
                 { file: 'admin/tracker/_tracker.component.html', method: 'processHtml' },
-                'shared/tracker/_tracker.service.ts',
-                'shared/tracker/_window.service.ts'
+                'core/tracker/_tracker.service.ts',
+                'core/tracker/_window.service.ts'
             ]
         },
         {
@@ -370,6 +370,42 @@ const files = {
             ]
         }
     ],
+    angularCore: [
+        {
+            path: ANGULAR_DIR,
+            templates: [
+                'core/_index.ts',
+                'core/_core.module.ts',
+                // login
+                'core/login/_login.service.ts',
+                'core/user/_account.model.ts'
+            ]
+        },
+        {
+            path: ANGULAR_DIR,
+            condition: generator => generator.authenticationType !== 'oauth2',
+            templates: [
+                // login
+                'core/login/_login-modal.service.ts'
+            ]
+        },
+        {
+            condition: generator => !generator.skipUserManagement || generator.authenticationType === 'oauth2',
+            path: ANGULAR_DIR,
+            templates: [
+                'core/user/_user.service.ts',
+                'core/user/_user.model.ts'
+            ]
+        },
+        {
+            condition: generator => generator.enableTranslation,
+            path: ANGULAR_DIR,
+            templates: [
+                'core/language/_language.constants.ts',
+                'core/language/_language.helper.ts'
+            ]
+        }
+    ],
     angularShared: [
         {
             path: ANGULAR_DIR,
@@ -382,9 +418,6 @@ const files = {
                 'shared/constants/_pagination.constants.ts',
                 // models
                 'shared/util/_request-util.ts',
-                'shared/user/_account.model.ts',
-                // login
-                'shared/login/_login.service.ts',
                 // alert service code
                 'shared/alert/_alert.component.ts',
                 'shared/alert/_alert-error.component.ts'
@@ -396,25 +429,14 @@ const files = {
             templates: [
                 // login
                 'shared/login/_login.component.ts',
-                { file: 'shared/login/_login.component.html', method: 'processHtml' },
-                'shared/login/_login-modal.service.ts'
+                { file: 'shared/login/_login.component.html', method: 'processHtml' }
             ]
         },
         {
             condition: generator => generator.enableTranslation,
             path: ANGULAR_DIR,
             templates: [
-                'shared/language/_find-language-from-key.pipe.ts',
-                'shared/language/_language.constants.ts',
-                'shared/language/_language.helper.ts'
-            ]
-        },
-        {
-            condition: generator => !generator.skipUserManagement || generator.authenticationType === 'oauth2',
-            path: ANGULAR_DIR,
-            templates: [
-                'shared/user/_user.model.ts',
-                'shared/user/_user.service.ts'
+                'shared/language/_find-language-from-key.pipe.ts'
             ]
         }
     ],
@@ -422,26 +444,26 @@ const files = {
         {
             path: ANGULAR_DIR,
             templates: [
-                'shared/auth/_csrf.service.ts',
-                'shared/auth/_state-storage.service.ts',
-                'shared/auth/_principal.service.ts',
+                'core/auth/_csrf.service.ts',
+                'core/auth/_state-storage.service.ts',
+                'core/auth/_principal.service.ts',
                 'shared/auth/_has-any-authority.directive.ts',
-                'shared/auth/_account.service.ts',
-                'shared/auth/_user-route-access-service.ts'
+                'core/auth/_account.service.ts',
+                'core/auth/_user-route-access-service.ts'
             ]
         },
         {
             condition: generator => generator.authenticationType === 'jwt' || generator.authenticationType === 'uaa',
             path: ANGULAR_DIR,
             templates: [
-                'shared/auth/_auth-jwt.service.ts'
+                'core/auth/_auth-jwt.service.ts'
             ]
         },
         {
             condition: generator => generator.authenticationType === 'session' || generator.authenticationType === 'oauth2',
             path: ANGULAR_DIR,
             templates: [
-                'shared/auth/_auth-session.service.ts'
+                'core/auth/_auth-session.service.ts'
             ]
         }
     ],
@@ -495,7 +517,7 @@ const files = {
                 'spec/app/admin/user-management/_user-management-dialog.component.spec.ts',
                 'spec/app/admin/user-management/_user-management-delete-dialog.component.spec.ts',
                 // user service tests
-                'spec/app/shared/user/_user.service.spec.ts'
+                'spec/app/core/user/_user.service.spec.ts'
             ]
         },
         {
diff --git a/generators/client/templates/angular/src/main/webapp/app/_app.module.ts b/generators/client/templates/angular/src/main/webapp/app/_app.module.ts
index d7d77b8223..d7ff95efb9 100644
--- a/generators/client/templates/angular/src/main/webapp/app/_app.module.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/_app.module.ts
@@ -30,7 +30,8 @@ import { AuthInterceptor } from './blocks/interceptor/auth.interceptor';
 import { AuthExpiredInterceptor } from './blocks/interceptor/auth-expired.interceptor';
 import { ErrorHandlerInterceptor } from './blocks/interceptor/errorhandler.interceptor';
 import { NotificationInterceptor } from './blocks/interceptor/notification.interceptor';
-import { <%=angularXAppName%>SharedModule, UserRouteAccessService } from 'app/shared';
+import { <%=angularXAppName%>SharedModule } from 'app/shared';
+import { <%=angularXAppName%>CoreModule } from 'app/core';
 import { <%=angularXAppName%>AppRoutingModule} from './app-routing.module';
 import { <%=angularXAppName%>HomeModule } from './home/home.module';
 import { <%=angularXAppName%>AdminModule } from './admin/admin.module';
@@ -40,7 +41,7 @@ import { <%=angularXAppName%>AccountModule } from './account/account.module';
 import { <%=angularXAppName%>EntityModule } from './entities/entity.module';
 import { PaginationConfig } from './blocks/config/uib-pagination.config';
 <%_ if (['session', 'oauth2'].includes(authenticationType)) { _%>
-import { StateStorageService } from 'app/shared/auth/state-storage.service';
+import { StateStorageService } from 'app/core/auth/state-storage.service';
 <%_ } _%>
 // jhipster-needle-angular-add-module-import JHipster will add new module here
 import {
@@ -61,6 +62,7 @@ import {
         <%=angularXAppName%>AppRoutingModule,
         Ng2Webstorage.forRoot({ prefix: '<%=jhiPrefixDashed %>', separator: '-'}),
         <%=angularXAppName%>SharedModule,
+        <%=angularXAppName%>CoreModule,
         <%=angularXAppName%>HomeModule,
         <%=angularXAppName%>AdminModule,
         <%_ if (authenticationType !== 'oauth2') { _%>
@@ -82,7 +84,6 @@ import {
     providers: [
         ProfileService,
         PaginationConfig,
-        UserRouteAccessService,
         <%_ if (authenticationType === 'jwt') { _%>
         {
             provide: HTTP_INTERCEPTORS,
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/activate/_activate.component.ts b/generators/client/templates/angular/src/main/webapp/app/account/activate/_activate.component.ts
index 6994062741..7b56248a5a 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/activate/_activate.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/activate/_activate.component.ts
@@ -20,7 +20,7 @@ import { Component, OnInit } from '@angular/core';
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
 import { ActivatedRoute } from '@angular/router';
 
-import { LoginModalService } from 'app/shared';
+import { LoginModalService } from 'app/core';
 import { ActivateService } from './activate.service';
 
 @Component({
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/activate/_activate.route.ts b/generators/client/templates/angular/src/main/webapp/app/account/activate/_activate.route.ts
index 3d2339e37c..3c05036881 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/activate/_activate.route.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/activate/_activate.route.ts
@@ -18,7 +18,7 @@
 -%>
 import { Route } from '@angular/router';
 
-import { UserRouteAccessService } from 'app/shared';
+import { UserRouteAccessService } from 'app/core';
 import { ActivateComponent } from './activate.component';
 
 export const activateRoute: Route = {
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/_password-reset-finish.component.ts b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/_password-reset-finish.component.ts
index 32b1f887ba..10a988a520 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/_password-reset-finish.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/_password-reset-finish.component.ts
@@ -20,7 +20,7 @@ import { Component, OnInit, AfterViewInit, Renderer, ElementRef } from '@angular
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
 import { ActivatedRoute } from '@angular/router';
 
-import { LoginModalService } from 'app/shared';
+import { LoginModalService } from 'app/core';
 import { PasswordResetFinishService } from './password-reset-finish.service';
 
 @Component({
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/_password-reset-finish.route.ts b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/_password-reset-finish.route.ts
index bf227ccf1c..f2750e910b 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/_password-reset-finish.route.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/_password-reset-finish.route.ts
@@ -18,7 +18,7 @@
 -%>
 import { Route } from '@angular/router';
 
-import { UserRouteAccessService } from 'app/shared';
+import { UserRouteAccessService } from 'app/core';
 import { PasswordResetFinishComponent } from './password-reset-finish.component';
 
 export const passwordResetFinishRoute: Route = {
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/_password-reset-init.component.ts b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/_password-reset-init.component.ts
index c7241e21ed..a1e032710f 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/_password-reset-init.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/_password-reset-init.component.ts
@@ -17,10 +17,10 @@
  limitations under the License.
 -%>
 import { Component, OnInit, AfterViewInit, Renderer, ElementRef } from '@angular/core';
-
 import { EMAIL_NOT_FOUND_TYPE } from 'app/shared';
 import { PasswordResetInitService } from './password-reset-init.service';
 
+
 @Component({
     selector: '<%= jhiPrefixDashed %>-password-reset-init',
     templateUrl: './password-reset-init.component.html'
@@ -54,7 +54,7 @@ export class PasswordResetInitComponent implements OnInit, AfterViewInit {
             this.success = 'OK';
         }, (response) => {
             this.success = null;
-            if (response.status === 400 && response.json().type === EMAIL_NOT_FOUND_TYPE) {
+            if (response.status === 400 && response.error.type === EMAIL_NOT_FOUND_TYPE) {
                 this.errorEmailNotExists = 'ERROR';
             } else {
                 this.error = 'ERROR';
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/_password-reset-init.route.ts b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/_password-reset-init.route.ts
index e5729e3307..0db16c7bef 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/_password-reset-init.route.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/_password-reset-init.route.ts
@@ -18,7 +18,7 @@
 -%>
 import { Route } from '@angular/router';
 
-import { UserRouteAccessService } from 'app/shared';
+import { UserRouteAccessService } from 'app/core';
 import { PasswordResetInitComponent } from './password-reset-init.component';
 
 export const passwordResetInitRoute: Route = {
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password/_password.component.ts b/generators/client/templates/angular/src/main/webapp/app/account/password/_password.component.ts
index 4685b8f4aa..dca5d94671 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/password/_password.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/password/_password.component.ts
@@ -18,7 +18,7 @@
 -%>
 import { Component, OnInit } from '@angular/core';
 
-import { Principal } from 'app/shared';
+import { Principal } from 'app/core';
 import { PasswordService } from './password.service';
 
 @Component({
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password/_password.route.ts b/generators/client/templates/angular/src/main/webapp/app/account/password/_password.route.ts
index 92ab6ae516..ba3d6f3303 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/password/_password.route.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/password/_password.route.ts
@@ -18,7 +18,7 @@
 -%>
 import { Route } from '@angular/router';
 
-import { UserRouteAccessService } from 'app/shared';
+import { UserRouteAccessService } from 'app/core';
 import { PasswordComponent } from './password.component';
 
 export const passwordRoute: Route = {
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/register/_register.component.ts b/generators/client/templates/angular/src/main/webapp/app/account/register/_register.component.ts
index e1d5c053eb..c8abb6dcac 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/register/_register.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/register/_register.component.ts
@@ -21,7 +21,8 @@ import { HttpErrorResponse } from '@angular/common/http';
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
 import { JhiLanguageService } from 'ng-jhipster';
 
-import { LoginModalService, EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from 'app/shared';
+import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from 'app/shared';
+import { LoginModalService } from 'app/core';
 import { Register } from './register.service';
 
 @Component({
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/sessions/_sessions.component.ts b/generators/client/templates/angular/src/main/webapp/app/account/sessions/_sessions.component.ts
index edefadcfc5..ec9f22af84 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/sessions/_sessions.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/sessions/_sessions.component.ts
@@ -18,7 +18,7 @@
 -%>
 import { Component, OnInit } from '@angular/core';
 
-import { Principal } from 'app/shared';
+import { Principal } from 'app/core';
 import { Session } from './session.model';
 import { SessionsService } from './sessions.service';
 
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/sessions/_sessions.route.ts b/generators/client/templates/angular/src/main/webapp/app/account/sessions/_sessions.route.ts
index 1f374f708a..8b5cc8c784 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/sessions/_sessions.route.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/sessions/_sessions.route.ts
@@ -18,7 +18,7 @@
 -%>
 import { Route } from '@angular/router';
 
-import { UserRouteAccessService } from 'app/shared';
+import { UserRouteAccessService } from 'app/core';
 import { SessionsComponent } from './sessions.component';
 
 export const sessionsRoute: Route = {
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/settings/_settings.component.ts b/generators/client/templates/angular/src/main/webapp/app/account/settings/_settings.component.ts
index 024c1d2c71..6dee898063 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/settings/_settings.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/settings/_settings.component.ts
@@ -19,7 +19,7 @@
 import { Component, OnInit } from '@angular/core';
 import { JhiLanguageService } from 'ng-jhipster';
 
-import { Principal, AccountService<% if (enableTranslation) { %>, JhiLanguageHelper<% } %> } from 'app/shared';
+import { Principal, AccountService<% if (enableTranslation) { %>, JhiLanguageHelper<% } %> } from 'app/core';
 
 @Component({
     selector: '<%= jhiPrefixDashed %>-settings',
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/settings/_settings.route.ts b/generators/client/templates/angular/src/main/webapp/app/account/settings/_settings.route.ts
index 4c0ad98b2b..9aee68675b 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/settings/_settings.route.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/settings/_settings.route.ts
@@ -18,7 +18,7 @@
 -%>
 import { Route } from '@angular/router';
 
-import { UserRouteAccessService } from 'app/shared';
+import { UserRouteAccessService } from 'app/core';
 import { SettingsComponent } from './settings.component';
 
 export const settingsRoute: Route = {
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/social/_social-auth.component.ts b/generators/client/templates/angular/src/main/webapp/app/account/social/_social-auth.component.ts
index 05f0fbfea3..dba70403ba 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/social/_social-auth.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/social/_social-auth.component.ts
@@ -20,7 +20,7 @@ import { Component, OnInit } from '@angular/core';
 import { Router } from '@angular/router';
 import { CookieService } from 'ngx-cookie';
 
-import { LoginService } from 'app/shared';
+import { LoginService } from 'app/core';
 
 @Component({
     selector: '<%= jhiPrefixDashed %>-auth',
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/social/_social-register.component.ts b/generators/client/templates/angular/src/main/webapp/app/account/social/_social-register.component.ts
index 6ddf789b7e..f6e98c1ee9 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/social/_social-register.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/social/_social-register.component.ts
@@ -20,7 +20,7 @@ import { Component, OnInit } from '@angular/core';
 import { ActivatedRoute } from '@angular/router';
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
 
-import { LoginModalService } from 'app/shared';
+import { LoginModalService } from 'app/core';
 
 @Component({
     selector: '<%= jhiPrefixDashed %>-register',
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/social/_social.route.ts b/generators/client/templates/angular/src/main/webapp/app/account/social/_social.route.ts
index a0a9dcd437..ec443f7ee8 100644
--- a/generators/client/templates/angular/src/main/webapp/app/account/social/_social.route.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/account/social/_social.route.ts
@@ -18,7 +18,7 @@
 -%>
 import { Route } from '@angular/router';
 
-import { UserRouteAccessService } from 'app/shared';
+import { UserRouteAccessService } from 'app/core';
 import { SocialRegisterComponent } from './social-register.component';
 <%_ if (authenticationType === 'jwt') { _%>
 import { SocialAuthComponent } from './social-auth.component';
diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/_admin.module.ts b/generators/client/templates/angular/src/main/webapp/app/admin/_admin.module.ts
index 2674c3f297..d56af6438d 100644
--- a/generators/client/templates/angular/src/main/webapp/app/admin/_admin.module.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/admin/_admin.module.ts
@@ -19,9 +19,6 @@
 import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
 import { RouterModule } from '@angular/router';
 
-<%_ if (websocket === 'spring-websocket') { _%>
-import { <%=jhiPrefixCapitalized%>TrackerService } from 'app/shared/tracker/tracker.service';
-<%_ } _%>
 import { <%=angularXAppName%>SharedModule } from 'app/shared';
 /* jhipster-needle-add-admin-module-import - JHipster will add admin modules imports here */
 
@@ -119,9 +116,6 @@ import {
         GatewayRoutesService,
         <%_ } _%>
         LogsService,
-        <%_ if (websocket === 'spring-websocket') { _%>
-        <%=jhiPrefixCapitalized%>TrackerService,
-        <%_ } _%>
         <%_ if (!skipUserManagement) { _%>
         UserResolvePagingParams,
         UserResolve,
diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/_admin.route.ts b/generators/client/templates/angular/src/main/webapp/app/admin/_admin.route.ts
index e7201ddb46..bb9e78ac81 100644
--- a/generators/client/templates/angular/src/main/webapp/app/admin/_admin.route.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/admin/_admin.route.ts
@@ -39,7 +39,7 @@ import {
     <%_ } _%>
 } from './';
 
-import { UserRouteAccessService } from 'app/shared';
+import { UserRouteAccessService } from 'app/core';
 
 const ADMIN_ROUTES = [
     <%_ if (databaseType !== 'no' && databaseType !== 'cassandra') { _%>
diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/tracker/_tracker.component.ts b/generators/client/templates/angular/src/main/webapp/app/admin/tracker/_tracker.component.ts
index 83fec94d88..c8a5bf462b 100644
--- a/generators/client/templates/angular/src/main/webapp/app/admin/tracker/_tracker.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/admin/tracker/_tracker.component.ts
@@ -18,7 +18,7 @@
 -%>
 import { Component, OnInit, OnDestroy } from '@angular/core';
 
-import { <%=jhiPrefixCapitalized%>TrackerService } from 'app/shared';
+import { <%=jhiPrefixCapitalized%>TrackerService } from 'app/core';
 
 @Component({
     selector: '<%= jhiPrefixDashed %>-tracker',
diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management-delete-dialog.component.ts b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management-delete-dialog.component.ts
index 566be0c2a0..17bdf92224 100644
--- a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management-delete-dialog.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management-delete-dialog.component.ts
@@ -21,7 +21,7 @@ import { ActivatedRoute } from '@angular/router';
 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
 import { JhiEventManager } from 'ng-jhipster';
 
-import { User, UserService } from 'app/shared';
+import { User, UserService } from 'app/core';
 import { UserModalService } from './user-modal.service';
 
 @Component({
diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management-detail.component.ts b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management-detail.component.ts
index 00632e10f5..cabbfe7d86 100644
--- a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management-detail.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management-detail.component.ts
@@ -20,7 +20,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core';
 import { ActivatedRoute } from '@angular/router';
 import { Subscription } from 'rxjs/Subscription';
 
-import { User, UserService } from 'app/shared';
+import { User, UserService } from 'app/core';
 
 @Component({
     selector: '<%= jhiPrefixDashed %>-user-mgmt-detail',
diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management-dialog.component.ts b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management-dialog.component.ts
index 0ce6d55d56..f1ac6781b3 100644
--- a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management-dialog.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management-dialog.component.ts
@@ -22,7 +22,7 @@ import { ActivatedRoute } from '@angular/router';
 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
 import { JhiEventManager } from 'ng-jhipster';
 
-import { <% if (enableTranslation) { %>JhiLanguageHelper,<% } %> User, UserService } from 'app/shared';
+import { <% if (enableTranslation) { %>JhiLanguageHelper,<% } %> User, UserService } from 'app/core';
 import { UserModalService } from './user-modal.service';
 
 @Component({
diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management.component.ts b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management.component.ts
index dba59d18ba..d5e4a5b570 100644
--- a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management.component.ts
@@ -22,11 +22,12 @@ import { HttpResponse } from '@angular/common/http';
 import { ActivatedRoute, Router } from '@angular/router';
 import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster';
 
-import { ITEMS_PER_PAGE, Principal, User, UserService } from 'app/shared';
+import { ITEMS_PER_PAGE } from 'app/shared';
+import { Principal, UserService, User } from 'app/core';
 <%_ } else { _%>
 import { JhiEventManager, JhiAlertService } from 'ng-jhipster';
 
-import { Principal, User, UserService } from 'app/shared';
+import { Principal, UserService, User } from 'app/core';
 <%_ } _%>
 
 @Component({
diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management.route.ts b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management.route.ts
index e91eafc702..176a3825a5 100644
--- a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management.route.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-management.route.ts
@@ -20,7 +20,7 @@ import { Injectable } from '@angular/core';
 import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes, CanActivate } from '@angular/router';
 import { JhiPaginationUtil } from 'ng-jhipster';
 
-import { Principal } from 'app/shared';
+import { Principal } from 'app/core';
 import { UserMgmtComponent } from './user-management.component';
 import { UserMgmtDetailComponent } from './user-management-detail.component';
 import { UserDialogComponent } from './user-management-dialog.component';
diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-modal.service.ts b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-modal.service.ts
index 972358d3c5..a5571ac5ad 100644
--- a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-modal.service.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/_user-modal.service.ts
@@ -20,7 +20,7 @@ import { Injectable, Component } from '@angular/core';
 import { Router } from '@angular/router';
 import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
 
-import { User, UserService } from 'app/shared';
+import { User, UserService } from 'app/core';
 
 @Injectable()
 export class UserModalService {
diff --git a/generators/client/templates/angular/src/main/webapp/app/blocks/interceptor/_auth-expired.interceptor.ts b/generators/client/templates/angular/src/main/webapp/app/blocks/interceptor/_auth-expired.interceptor.ts
index 9f3492260a..0c07a0f8d7 100644
--- a/generators/client/templates/angular/src/main/webapp/app/blocks/interceptor/_auth-expired.interceptor.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/blocks/interceptor/_auth-expired.interceptor.ts
@@ -23,17 +23,18 @@ import 'rxjs/add/operator/do';
 <%_ if (['oauth2', 'jwt', 'uaa'].includes(authenticationType)) { _%>
     <%_ if (authenticationType === 'uaa') { _%>
 import { Router } from '@angular/router';
-import { LoginModalService } from 'app/shared/login/login-modal.service';
-import { Principal } from 'app/shared/auth/principal.service';
+
+import { LoginModalService } from 'app/core/login/login-modal.service';
+import { Principal } from 'app/core/auth/principal.service';
     <%_ } _%>
-import { LoginService } from 'app/shared/login/login.service';
+import { LoginService } from 'app/core/login/login.service';
 <%_ } _%>
 <%_ if (['session', 'oauth2'].includes(authenticationType)) { _%>
     <%_ if (authenticationType === 'session') { _%>
-import { AuthServerProvider } from 'app/shared/auth/auth-session.service';
-import { LoginModalService } from 'app/shared/login/login-modal.service';
+import { AuthServerProvider } from 'app/core/auth/auth-session.service';
+import { LoginModalService } from 'app/core/login/login-modal.service';
     <%_ } _%>
-import { StateStorageService } from 'app/shared/auth/state-storage.service';
+import { StateStorageService } from 'app/core/auth/state-storage.service';
 <%_ } _%>
 
 export class AuthExpiredInterceptor implements HttpInterceptor {
diff --git a/generators/client/templates/angular/src/main/webapp/app/core/_core.module.ts b/generators/client/templates/angular/src/main/webapp/app/core/_core.module.ts
new file mode 100644
index 0000000000..07edd7c955
--- /dev/null
+++ b/generators/client/templates/angular/src/main/webapp/app/core/_core.module.ts
@@ -0,0 +1,83 @@
+import { NgModule, LOCALE_ID } from '@angular/core';
+import { DatePipe, registerLocaleData } from '@angular/common';
+import { Title } from '@angular/platform-browser';
+<%_ const localeId = getLocaleId(nativeLanguage); _%>
+import locale from '@angular/common/locales/<%= localeId %>';
+
+import {
+    <%_ if (websocket === 'spring-websocket') { _%>
+    <%=jhiPrefixCapitalized%>TrackerService,
+    WindowRef,
+    <%_ } _%>
+    <%_ if (enableTranslation) { _%>
+    JhiLanguageHelper,
+    <%_ } _%>
+    LoginService,
+    <%_ if (authenticationType !== 'oauth2') { _%>
+    LoginModalService,
+    <%_ } _%>
+    <%_ if (enableSocialSignIn) { _%>
+    SocialService,
+    <%_ } _%>
+    AccountService,
+    StateStorageService,
+    Principal,
+    CSRFService,
+    AuthServerProvider,
+    <%_ if (!skipUserManagement || authenticationType === 'oauth2') { _%>
+    UserService,
+    <%_ } _%>
+    UserRouteAccessService
+} from './';
+<%_ if (enableI18nRTL) { _%>
+import {
+    FindLanguageFromKeyPipe
+} from 'app/shared';<%_ } _%>
+
+@NgModule({
+    imports: [],
+    exports: [],
+    declarations: [],
+    providers: [
+        <%_ if (websocket === 'spring-websocket') { _%>
+        <%=jhiPrefixCapitalized%>TrackerService,
+        WindowRef,
+        <%_ } _%>
+        LoginService,
+        <%_ if (authenticationType !== 'oauth2') { _%>
+        LoginModalService,
+        <%_ } _%>
+        <%_ if (enableSocialSignIn) { _%>
+        SocialService,
+        <%_ } _%>
+        Title,
+        {
+            provide: LOCALE_ID,
+        <%_ if (skipLanguageForLocale(nativeLanguage)) { _%>
+            useValue: 'en'
+        <%_ } else { _%>
+            useValue: '<%= localeId %>'
+        <%_ } _%>
+        },
+        <%_ if (enableI18nRTL) { _%>
+        FindLanguageFromKeyPipe,
+        <%_ } if (enableTranslation) { _%>
+        JhiLanguageHelper,
+        <%_ } _%>
+        AccountService,
+        StateStorageService,
+        Principal,
+        CSRFService,
+        AuthServerProvider,
+        <%_ if (!skipUserManagement || authenticationType === 'oauth2') { _%>
+        UserService,
+        <%_ } _%>
+        DatePipe,
+        UserRouteAccessService
+    ]
+})
+export class <%=angularXAppName%>CoreModule {
+    constructor() {
+        registerLocaleData(locale);
+    }
+}
diff --git a/generators/client/templates/angular/src/main/webapp/app/core/_index.ts b/generators/client/templates/angular/src/main/webapp/app/core/_index.ts
new file mode 100644
index 0000000000..913b8f7f96
--- /dev/null
+++ b/generators/client/templates/angular/src/main/webapp/app/core/_index.ts
@@ -0,0 +1,31 @@
+export * from './auth/csrf.service';
+export * from './auth/state-storage.service';
+export * from './auth/account.service';
+<%_ if (authenticationType === 'jwt' || authenticationType === 'uaa') { _%>
+export * from './auth/auth-jwt.service';
+<%_ } else if (authenticationType === 'session' || authenticationType === 'oauth2') { _%>
+export * from './auth/auth-session.service';
+<%_ } _%>
+<%_ if (websocket === 'spring-websocket') { _%>
+export * from './tracker/tracker.service';
+export * from './tracker/window.service';
+<%_ } _%>
+<%_ if (enableSocialSignIn) { _%>
+export * from './social/social.service';
+<%_ } _%>
+<%_ if (enableTranslation) { _%>
+export * from './language/language.helper';
+export * from './language/language.constants';
+<%_ } _%>
+export * from './user/account.model';
+<%_ if (!skipUserManagement || authenticationType === 'oauth2') { _%>
+export * from './user/user.model';
+<%_ } _%>
+export * from './auth/principal.service';
+export * from './auth/user-route-access-service';
+<%_ if (authenticationType !== 'oauth2') { _%> 
+export * from './login/login-modal.service';
+<%_ } _%> 
+export * from './login/login.service';
+export * from './user/user.service';
+export * from './core.module';
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/auth/_account.service.ts b/generators/client/templates/angular/src/main/webapp/app/core/auth/_account.service.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/auth/_account.service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/auth/_account.service.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/auth/_auth-jwt.service.ts b/generators/client/templates/angular/src/main/webapp/app/core/auth/_auth-jwt.service.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/auth/_auth-jwt.service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/auth/_auth-jwt.service.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/auth/_auth-session.service.ts b/generators/client/templates/angular/src/main/webapp/app/core/auth/_auth-session.service.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/auth/_auth-session.service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/auth/_auth-session.service.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/auth/_csrf.service.ts b/generators/client/templates/angular/src/main/webapp/app/core/auth/_csrf.service.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/auth/_csrf.service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/auth/_csrf.service.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/auth/_principal.service.ts b/generators/client/templates/angular/src/main/webapp/app/core/auth/_principal.service.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/auth/_principal.service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/auth/_principal.service.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/auth/_state-storage.service.ts b/generators/client/templates/angular/src/main/webapp/app/core/auth/_state-storage.service.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/auth/_state-storage.service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/auth/_state-storage.service.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/auth/_user-route-access-service.ts b/generators/client/templates/angular/src/main/webapp/app/core/auth/_user-route-access-service.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/auth/_user-route-access-service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/auth/_user-route-access-service.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/language/_language.constants.ts b/generators/client/templates/angular/src/main/webapp/app/core/language/_language.constants.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/language/_language.constants.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/language/_language.constants.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/language/_language.helper.ts b/generators/client/templates/angular/src/main/webapp/app/core/language/_language.helper.ts
similarity index 95%
rename from generators/client/templates/angular/src/main/webapp/app/shared/language/_language.helper.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/language/_language.helper.ts
index b0357fd634..b3be625452 100644
--- a/generators/client/templates/angular/src/main/webapp/app/shared/language/_language.helper.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/core/language/_language.helper.ts
@@ -21,9 +21,9 @@ import { Title } from '@angular/platform-browser';
 import { Router, ActivatedRouteSnapshot } from '@angular/router';
 import { TranslateService, LangChangeEvent } from '@ngx-translate/core';
 
-import { LANGUAGES } from './language.constants';
+import { LANGUAGES } from 'app/core/language/language.constants';
 <%_ if (enableI18nRTL) { _%>
-import { FindLanguageFromKeyPipe } from './find-language-from-key.pipe';
+import { FindLanguageFromKeyPipe } from 'app/shared/language/find-language-from-key.pipe';
 <%_ } _%>
 
 @Injectable()
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/login/_login-modal.service.ts b/generators/client/templates/angular/src/main/webapp/app/core/login/_login-modal.service.ts
similarity index 93%
rename from generators/client/templates/angular/src/main/webapp/app/shared/login/_login-modal.service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/login/_login-modal.service.ts
index 4393a30ef6..12ec6dc727 100644
--- a/generators/client/templates/angular/src/main/webapp/app/shared/login/_login-modal.service.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/core/login/_login-modal.service.ts
@@ -19,7 +19,7 @@
 import { Injectable } from '@angular/core';
 import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
 
-import { <%=jhiPrefixCapitalized%>LoginModalComponent } from './login.component';
+import { <%=jhiPrefixCapitalized%>LoginModalComponent } from 'app/shared/login/login.component';
 
 @Injectable()
 export class LoginModalService {
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/login/_login.service.ts b/generators/client/templates/angular/src/main/webapp/app/core/login/_login.service.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/login/_login.service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/login/_login.service.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/social/_social.service.ts b/generators/client/templates/angular/src/main/webapp/app/core/social/_social.service.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/social/_social.service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/social/_social.service.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/tracker/_tracker.service.ts b/generators/client/templates/angular/src/main/webapp/app/core/tracker/_tracker.service.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/tracker/_tracker.service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/tracker/_tracker.service.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/tracker/_window.service.ts b/generators/client/templates/angular/src/main/webapp/app/core/tracker/_window.service.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/tracker/_window.service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/tracker/_window.service.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/user/_account.model.ts b/generators/client/templates/angular/src/main/webapp/app/core/user/_account.model.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/user/_account.model.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/user/_account.model.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/user/_user.model.ts b/generators/client/templates/angular/src/main/webapp/app/core/user/_user.model.ts
similarity index 100%
rename from generators/client/templates/angular/src/main/webapp/app/shared/user/_user.model.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/user/_user.model.ts
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/user/_user.service.ts b/generators/client/templates/angular/src/main/webapp/app/core/user/_user.service.ts
similarity index 97%
rename from generators/client/templates/angular/src/main/webapp/app/shared/user/_user.service.ts
rename to generators/client/templates/angular/src/main/webapp/app/core/user/_user.service.ts
index 55a816599d..76a504f765 100644
--- a/generators/client/templates/angular/src/main/webapp/app/shared/user/_user.service.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/core/user/_user.service.ts
@@ -21,8 +21,8 @@ import { HttpClient, HttpResponse } from '@angular/common/http';
 import { Observable } from 'rxjs/Observable';
 
 import { SERVER_API_URL } from 'app/app.constants';
+import { createRequestOption } from 'app/shared/util/request-util';
 import { IUser } from './user.model';
-import { createRequestOption } from '../util/request-util';
 
 @Injectable()
 export class UserService {
diff --git a/generators/client/templates/angular/src/main/webapp/app/home/_home.component.ts b/generators/client/templates/angular/src/main/webapp/app/home/_home.component.ts
index 9fb153a614..da2df3d421 100644
--- a/generators/client/templates/angular/src/main/webapp/app/home/_home.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/home/_home.component.ts
@@ -22,7 +22,7 @@ import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
 <%_ } _%>
 import { JhiEventManager } from 'ng-jhipster';
 
-import { Account, <% if (authenticationType !== 'oauth2') { %>LoginModalService<% } else { %>LoginService<% } %>, Principal } from 'app/shared';
+import { <% if (authenticationType !== 'oauth2') { %>LoginModalService<% } else { %>LoginService<% } %>, Principal, Account } from 'app/core';
 
 @Component({
     selector: '<%= jhiPrefixDashed %>-home',
diff --git a/generators/client/templates/angular/src/main/webapp/app/layouts/main/_main.component.ts b/generators/client/templates/angular/src/main/webapp/app/layouts/main/_main.component.ts
index 99021ada34..0bae640d89 100644
--- a/generators/client/templates/angular/src/main/webapp/app/layouts/main/_main.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/layouts/main/_main.component.ts
@@ -20,7 +20,7 @@ import { Component, OnInit } from '@angular/core';
 import { Router, ActivatedRouteSnapshot, NavigationEnd } from '@angular/router';
 
 <%_ if (enableTranslation) { _%>
-import { JhiLanguageHelper } from 'app/shared';
+import { JhiLanguageHelper } from 'app/core';
 <%_ } else { _%>
 import { Title } from '@angular/platform-browser';
 <%_ } _%>
diff --git a/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/_navbar.component.ts b/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/_navbar.component.ts
index 308e867082..7962b2048a 100644
--- a/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/_navbar.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/_navbar.component.ts
@@ -24,7 +24,7 @@ import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
 import { JhiLanguageService } from 'ng-jhipster';
 
 import { VERSION } from 'app/app.constants';
-import { <% if (enableTranslation) { %>JhiLanguageHelper, <% } %>Principal, <% if (authenticationType !== 'oauth2') { %>LoginModalService, <% } %>LoginService } from 'app/shared';
+import { <% if (enableTranslation) { %>JhiLanguageHelper, <% } %>Principal, <% if (authenticationType !== 'oauth2') { %>LoginModalService, <% } %>LoginService } from 'app/core';
 import { ProfileService } from '../profiles/profile.service';
 
 @Component({
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/_index.ts b/generators/client/templates/angular/src/main/webapp/app/shared/_index.ts
index 0e695e6a68..95c255a186 100644
--- a/generators/client/templates/angular/src/main/webapp/app/shared/_index.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/shared/_index.ts
@@ -20,38 +20,15 @@ export * from './constants/error.constants';
 export * from './constants/pagination.constants';
 export * from './alert/alert.component';
 export * from './alert/alert-error.component';
-export * from './auth/csrf.service';
-export * from './auth/state-storage.service';
-export * from './auth/account.service';
-<%_ if (authenticationType === 'jwt' || authenticationType === 'uaa') { _%>
-export * from './auth/auth-jwt.service';
-<%_ } else if (authenticationType === 'session' || authenticationType === 'oauth2') { _%>
-export * from './auth/auth-session.service';
-<%_ } _%>
-export * from './auth/principal.service';
 export * from './auth/has-any-authority.directive';
-export * from './auth/user-route-access-service';
 <%_ if (enableTranslation) { _%>
-export * from './language/language.constants';
-export * from './language/language.helper';
 export * from './language/find-language-from-key.pipe';
 <%_ } _%>
-<%_ if (websocket === 'spring-websocket') { _%>
-export * from './tracker/tracker.service';
-<%_ } _%>
 <%_ if (authenticationType !== 'oauth2') { _%>
 export * from './login/login.component';
-export * from './login/login-modal.service';
-<%_ } _%>
-export * from './login/login.service';
-export * from './user/account.model';
-<%_ if (!skipUserManagement || authenticationType === 'oauth2') { _%>
-export * from './user/user.model';
-export * from './user/user.service';
 <%_ } _%>
 export * from './util/request-util';
 <%_ if (enableSocialSignIn) { _%>
-export * from './social/social.service';
 export * from './social/social.component';
 <%_ } _%>
 export * from './shared-libs.module';
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/_shared-common.module.ts b/generators/client/templates/angular/src/main/webapp/app/shared/_shared-common.module.ts
index 1a4300b1e0..8a58252e3a 100644
--- a/generators/client/templates/angular/src/main/webapp/app/shared/_shared-common.module.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/shared/_shared-common.module.ts
@@ -16,19 +16,11 @@
  See the License for the specific language governing permissions and
  limitations under the License.
 -%>
-import { NgModule, LOCALE_ID } from '@angular/core';
-import { Title } from '@angular/platform-browser';
-import { registerLocaleData } from '@angular/common';
-<%_ const localeId = getLocaleId(nativeLanguage); _%>
-import locale from '@angular/common/locales/<%= localeId %>';
+import { NgModule } from '@angular/core';
 
-<%_ if (websocket === 'spring-websocket') { _%>
-import { WindowRef } from './tracker/window.service';
-<%_ } _%>
 import {
     <%=angularXAppName%>SharedLibsModule,
     <%_ if (enableTranslation) { _%>
-    JhiLanguageHelper,
     FindLanguageFromKeyPipe,
     <%_ } _%>
     <%=jhiPrefixCapitalized%>AlertComponent,
@@ -46,24 +38,7 @@ import {
         <%=jhiPrefixCapitalized%>AlertComponent,
         <%=jhiPrefixCapitalized%>AlertErrorComponent
     ],
-    providers: [
-        <%_ if (enableI18nRTL) { _%>
-        FindLanguageFromKeyPipe,
-        <%_ } if (enableTranslation) { _%>
-        JhiLanguageHelper,
-        <%_ } if (websocket === 'spring-websocket') { _%>
-        WindowRef,
-        <%_ } _%>
-        Title,
-        {
-            provide: LOCALE_ID,
-        <%_ if (skipLanguageForLocale(nativeLanguage)) { _%>
-            useValue: 'en'
-        <%_ } else { _%>
-            useValue: '<%= localeId %>'
-        <%_ } _%>
-        },
-    ],
+    providers: [],
     exports: [
         <%=angularXAppName%>SharedLibsModule,
         <%_ if (enableTranslation) { _%>
@@ -73,8 +48,4 @@ import {
         <%=jhiPrefixCapitalized%>AlertErrorComponent
     ]
 })
-export class <%=angularXAppName%>SharedCommonModule {
-    constructor() {
-        registerLocaleData(locale);
-    }
-}
+export class <%=angularXAppName%>SharedCommonModule {}
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/_shared.module.ts b/generators/client/templates/angular/src/main/webapp/app/shared/_shared.module.ts
index 7f09c56032..9259287d91 100644
--- a/generators/client/templates/angular/src/main/webapp/app/shared/_shared.module.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/shared/_shared.module.ts
@@ -17,31 +17,16 @@
  limitations under the License.
 -%>
 import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
-import { DatePipe } from '@angular/common';
 
 import {
     <%=angularXAppName%>SharedLibsModule,
     <%=angularXAppName%>SharedCommonModule,
-    CSRFService,
-    AuthServerProvider,
-    AccountService,
-    <%_ if (!skipUserManagement || authenticationType === 'oauth2') { _%>
-    UserService,
-    <%_ } _%>
-    StateStorageService,
-    LoginService,
     <%_ if (authenticationType !== 'oauth2') { _%>
-    LoginModalService,
     <%=jhiPrefixCapitalized%>LoginModalComponent,
     <%_ } _%>
-    Principal,
-    <%_ if (websocket === 'spring-websocket') { _%>
-    <%=jhiPrefixCapitalized%>TrackerService,
-    <%_ } _%>
     HasAnyAuthorityDirective,
     <%_ if (enableSocialSignIn) { _%>
-    <%=jhiPrefixCapitalized%>SocialComponent,
-    SocialService,
+    <%=jhiPrefixCapitalized%>SocialComponent
     <%_ } _%>
 } from './';
 
@@ -59,27 +44,7 @@ import {
         <%_ } _%>
         HasAnyAuthorityDirective
     ],
-    providers: [
-        LoginService,
-        <%_ if (authenticationType !== 'oauth2') { _%>
-        LoginModalService,
-        <%_ } _%>
-        AccountService,
-        StateStorageService,
-        Principal,
-        CSRFService,
-        <%_ if (websocket === 'spring-websocket') { _%>
-        <%=jhiPrefixCapitalized%>TrackerService,
-        <%_ } _%>
-        AuthServerProvider,
-        <%_ if (enableSocialSignIn) { _%>
-        SocialService,
-        <%_ } _%>
-        <%_ if (!skipUserManagement || authenticationType === 'oauth2') { _%>
-        UserService,
-        <%_ } _%>
-        DatePipe
-    ],
+    providers: [],
     <%_ if (authenticationType !== 'oauth2') { _%>
     entryComponents: [<%=jhiPrefixCapitalized%>LoginModalComponent],
     <%_ } _%>
@@ -91,8 +56,7 @@ import {
         <%_ if (authenticationType !== 'oauth2') { _%>
         <%=jhiPrefixCapitalized%>LoginModalComponent,
         <%_ } _%>
-        HasAnyAuthorityDirective,
-        DatePipe
+        HasAnyAuthorityDirective
     ],
     schemas: [CUSTOM_ELEMENTS_SCHEMA]
 
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/auth/_has-any-authority.directive.ts b/generators/client/templates/angular/src/main/webapp/app/shared/auth/_has-any-authority.directive.ts
index 74b1864aec..c4665e1617 100644
--- a/generators/client/templates/angular/src/main/webapp/app/shared/auth/_has-any-authority.directive.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/shared/auth/_has-any-authority.directive.ts
@@ -17,7 +17,7 @@
  limitations under the License.
 -%>
 import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
-import { Principal } from './principal.service';
+import { Principal } from 'app/core/auth/principal.service';
 
 /**
  * @whatItDoes Conditionally includes an HTML element if current user has any
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/login/_login.component.ts b/generators/client/templates/angular/src/main/webapp/app/shared/login/_login.component.ts
index 7baaae57bf..bcdfcf00e9 100644
--- a/generators/client/templates/angular/src/main/webapp/app/shared/login/_login.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/shared/login/_login.component.ts
@@ -21,8 +21,8 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
 import { Router } from '@angular/router';
 import { JhiEventManager } from 'ng-jhipster';
 
-import { LoginService } from './login.service';
-import { StateStorageService } from '../auth/state-storage.service';
+import { LoginService } from 'app/core/login/login.service';
+import { StateStorageService } from 'app/core/auth/state-storage.service';
 
 @Component({
     selector: '<%= jhiPrefixDashed %>-login-modal',
diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/social/_social.component.ts b/generators/client/templates/angular/src/main/webapp/app/shared/social/_social.component.ts
index a16b5d87a3..afaf64cbf7 100644
--- a/generators/client/templates/angular/src/main/webapp/app/shared/social/_social.component.ts
+++ b/generators/client/templates/angular/src/main/webapp/app/shared/social/_social.component.ts
@@ -17,8 +17,9 @@
  limitations under the License.
 -%>
 import { Component, Input, OnInit } from '@angular/core';
-import { SocialService } from './social.service';
-import { CSRFService } from '../auth/csrf.service';
+
+import { SocialService } from 'app/core/social/social.service';
+import { CSRFService } from 'app/core/auth/csrf.service';
 
 @Component({
     selector: '<%= jhiPrefixDashed %>-social',
diff --git a/generators/docker-compose/templates/_jhipster-registry.yml b/generators/docker-compose/templates/_jhipster-registry.yml
index 9515ad9874..4a58af18ed 100644
--- a/generators/docker-compose/templates/_jhipster-registry.yml
+++ b/generators/docker-compose/templates/_jhipster-registry.yml
@@ -46,9 +46,11 @@ services:
             # For keycloak to work, you need to add '127.0.0.1 keycloak' to your hosts file
             - SECURITY_OAUTH2_CLIENT_ACCESS_TOKEN_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/token
             - SECURITY_OAUTH2_CLIENT_USER_AUTHORIZATION_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/auth
+            - SECURITY_OAUTH2_CLIENT_CLIENT_ID=<% if (applicationType === 'microservice') { %>internal<% } else { %>web_app<% } %>
+            - SECURITY_OAUTH2_CLIENT_CLIENT_SECRET=<% if (applicationType === 'microservice') { %>internal<% } else { %>web_app<% } %>
             - SECURITY_OAUTH2_RESOURCE_USER_INFO_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/userinfo
             - SECURITY_OAUTH2_RESOURCE_TOKEN_INFO_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/token/introspect
-            - SECURITY_OAUTH2_RESOURCE_JWT_KEY_URI=http://keycloak:9080/auth/realms/jhipster
+            - SECURITY_OAUTH2_RESOURCE_JWK_KEY_SET_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/certs
             <%_ } _%>
         ports:
             - 8761:8761
diff --git a/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity-management-dialog.component.ts b/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity-management-dialog.component.ts
index 6edd60e61f..52413ff9f9 100644
--- a/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity-management-dialog.component.ts
+++ b/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity-management-dialog.component.ts
@@ -53,7 +53,7 @@ Object.keys(differentRelationships).forEach(key => {
         if (uniqueRel.otherEntityAngularName !== entityAngularName) {
             if(uniqueRel.otherEntityAngularName === 'User') {
 _%>
-import { I<%= uniqueRel.otherEntityAngularName %>, <%= uniqueRel.otherEntityAngularName%>Service } from 'app/shared';
+import { I<%= uniqueRel.otherEntityAngularName %>, <%= uniqueRel.otherEntityAngularName%>Service } from 'app/core';
 <%_         } else { _%>
 import { I<%= uniqueRel.otherEntityAngularName %> } from 'app/shared/model/<%= uniqueRel.otherEntityModelName %>.model';
 import { <%= uniqueRel.otherEntityAngularName%>Service } from '../<%= uniqueRel.otherEntityModulePath %>';
diff --git a/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity-management.component.ts b/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity-management.component.ts
index ff8e78bd77..3a2392c469 100644
--- a/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity-management.component.ts
+++ b/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity-management.component.ts
@@ -27,7 +27,10 @@ import { Subscription } from 'rxjs/Subscription';
 import { JhiEventManager, <% if (pagination !== 'no') { %>JhiParseLinks, <% } %>JhiAlertService<% if (fieldsContainBlob) { %>, JhiDataUtils<% } %> } from 'ng-jhipster';
 
 import { I<%= entityAngularName %> } from 'app/shared/model/<%= entityModelFileName %>.model';
-import { <% if (pagination !== 'no') { %>ITEMS_PER_PAGE, <% } %>Principal } from 'app/shared';
+import { Principal } from 'app/core';
+<%_ if (pagination !== 'no') { %>
+import { ITEMS_PER_PAGE } from 'app/shared';
+<%_ } _%>
 import { <%= entityAngularName %>Service } from './<%= entityFileName %>.service';
 
 @Component({
diff --git a/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity-management.route.ts b/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity-management.route.ts
index 3e24d87e81..de34025d4d 100644
--- a/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity-management.route.ts
+++ b/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity-management.route.ts
@@ -38,7 +38,7 @@ import { <% if (pagination === 'pagination' || pagination === 'pager') { %>Resol
 import { JhiPaginationUtil } from 'ng-jhipster';
 <%_ } _%>
 
-import { UserRouteAccessService } from 'app/shared';
+import { UserRouteAccessService } from 'app/core';
 import { <%= entityAngularName %>Component } from './<%= entityFileName %>.component';
 import { <%= entityAngularName %>DetailComponent } from './<%= entityFileName %>-detail.component';
 import { <%= entityAngularName %>PopupComponent } from './<%= entityFileName %>-dialog.component';
diff --git a/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity.model.ts b/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity.model.ts
index 378be96a76..bc7c442fc9 100644
--- a/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity.model.ts
+++ b/generators/entity-client/templates/angular/src/main/webapp/app/entities/_entity.model.ts
@@ -81,7 +81,7 @@ relationships.forEach(relationship => {
 });
 _%>
 <%_ if (hasUserRelationship) { _%>
-import { IUser } from 'app/shared/user/user.model';
+import { IUser } from 'app/core/user/user.model';
 <%_ } _%>
 <%_ typeImports.forEach(typeImport => { _%>
 <%- typeImport %>;
diff --git a/generators/entity-server/templates/src/main/java/package/common/get_all_template.ejs b/generators/entity-server/templates/src/main/java/package/common/get_all_template.ejs
index c61b284bf3..5b56a81921 100644
--- a/generators/entity-server/templates/src/main/java/package/common/get_all_template.ejs
+++ b/generators/entity-server/templates/src/main/java/package/common/get_all_template.ejs
@@ -21,6 +21,7 @@
     const instanceName = (dto === 'mapstruct') ? entityInstance + 'DTO' : entityInstance;
     const mapper = entityInstance + 'Mapper';
     const entityListToDtoListReference = mapper + '.' + 'toDto';
+    const entityToDtoReference = mapper + '::'+ 'toDto';
     if (jpaMetamodelFiltering) {  %>
     public ResponseEntity<List<<%= instanceType %>>> getAll<%= entityClassPlural %>(<%= entityClass %>Criteria criteria<% if (pagination != 'no') { %>, Pageable pageable<% } %>) {
         log.debug("REST request to get <%= entityClassPlural %> by criteria: {}", criteria);
@@ -33,22 +34,35 @@
         return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
     <%_ } _%>
     }
-<%
-    } else {
-        if (pagination === 'no') { %>
-    public List<<%= instanceType %>> getAll<%= entityClassPlural %>(<% if (fieldsContainNoOwnerOneToOne) { %>@RequestParam(required = false) String filter<% } %>) {<%- include('get_all_stream_template', {viaService: viaService}); -%>
+<% } else { %>
+    <%_ if (pagination === 'no') { _%>
+    public List<<%= instanceType %>> getAll<%= entityClassPlural %>(<% if (fieldsContainNoOwnerOneToOne) { %>@RequestParam(required = false) String filter<% } %><% if (fieldsContainOwnerManyToMany && fieldsContainNoOwnerOneToOne) { %>,<% } %><% if (fieldsContainOwnerManyToMany) { %>@RequestParam(required = false, defaultValue = "false") boolean eagerload<% }%>) {<%- include('get_all_stream_template', {viaService: viaService}); -%>
         log.debug("REST request to get all <%= entityClassPlural %>");<% if (viaService) { %>
         return <%= entityInstance %>Service.findAll();<% } else if (dto === 'mapstruct') { %>
         List<<%= entityClass %>> <%= entityInstancePlural %> = <%= entityInstance %>Repository.<% if (fieldsContainOwnerManyToMany) { %>findAllWithEagerRelationships<% } else { %>findAll<% } %>();
         return <%= entityListToDtoListReference %>(<%= entityInstancePlural %>);<% } else { %>
         return <%= entityInstance %>Repository.<% if (fieldsContainOwnerManyToMany) { %>findAllWithEagerRelationships<% } else { %>findAll<% } %>();<% } %>
-    <% } if (pagination !== 'no') { %>
-    public ResponseEntity<List<<%= instanceType %>>> getAll<%= entityClassPlural %>(Pageable pageable<% if (fieldsContainNoOwnerOneToOne) { %>, @RequestParam(required = false) String filter<% } %>) {<%- include('get_all_stream_template', {viaService: viaService}); -%>
-        log.debug("REST request to get a page of <%= entityClassPlural %>");<% if (viaService) { %>
-        Page<<%= instanceType %>> page = <%= entityInstance %>Service.findAll(pageable);<% } else { %>
-        Page<<%= entityClass %>> page = <%= entityInstance %>Repository.findAll(pageable);<% } %>
+    <%_ } if (pagination !== 'no') { _%>
+    public ResponseEntity<List<<%= instanceType %>>> getAll<%= entityClassPlural %>(Pageable pageable<% if (fieldsContainNoOwnerOneToOne) { %>, @RequestParam(required = false) String filter<% } %><% if (fieldsContainOwnerManyToMany) { %>, @RequestParam(required = false, defaultValue = "false") boolean eagerload<% } %>) {<%- include('get_all_stream_template', {viaService: viaService}); -%>
+        log.debug("REST request to get a page of <%= entityClassPlural %>");
+    <%_ if (viaService) { _%>
+        <%_ if (fieldsContainOwnerManyToMany) { _%>
+        Page<<%= instanceType %>> page = eagerload ? <%= entityInstance %>Service.findAllWithEagerRelationships(pageable) : <%= entityInstance %>Service.findAll(pageable);
+        HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, String.format("/api/<%= entityApiUrl %>?eagerload=%b", eagerload));
+        <%_ } else { _%>
+        Page<<%= instanceType %>> page = <%= entityInstance %>Service.findAll(pageable);
+        HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/<%= entityApiUrl %>");
+        <%_ } _%>
+    <%_ } else { _%>
+        <%_ if (fieldsContainOwnerManyToMany) { _%>
+        Page<<%= instanceType %>> page = eagerload ? <%= entityInstance %>Repository.findAllWithEagerRelationships(pageable)<% if (dto === 'mapstruct') {%>.map(<%= entityToDtoReference %>)<% } %> : <%= entityInstance %>Repository.findAll(pageable)<% if (dto !== 'mapstruct') { %>;<% } else { %>.map(<%= entityToDtoReference %>);<% } %>
+        HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, String.format("/api/<%= entityApiUrl %>?eagerload=%b", eagerload));
+        <%_ } else { _%>
+        Page<<%= instanceType %>> page = <%= entityInstance %>Repository.findAll(pageable)<% if (dto !== 'mapstruct') { %>;<% } else { %>.map(<%= entityToDtoReference %>);<% } %>
         HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/<%= entityApiUrl %>");
-        return new ResponseEntity<>(<% if (!viaService && dto === 'mapstruct') { %><%= entityListToDtoListReference %>(page.getContent())<% } else { %>page.getContent()<% } %>, headers, HttpStatus.OK);
+        <%_ } _%>
+    <%_ } _%>
+        return new ResponseEntity<>(<% if (!viaService && dto === 'mapstruct' && fieldsContainOwnerManyToMany) { %><%= entityListToDtoListReference %>(page.getContent())<% } else { %>page.getContent()<% } %>, headers, HttpStatus.OK);
     <%_ } _%>
     }
 <%_ } _%>
diff --git a/generators/entity-server/templates/src/main/java/package/repository/_EntityRepository.java b/generators/entity-server/templates/src/main/java/package/repository/_EntityRepository.java
index 5de237e56b..44499bbd55 100644
--- a/generators/entity-server/templates/src/main/java/package/repository/_EntityRepository.java
+++ b/generators/entity-server/templates/src/main/java/package/repository/_EntityRepository.java
@@ -20,6 +20,8 @@ package <%=packageName%>.repository;
 
 import <%=packageName%>.domain.<%=entityClass%>;
 import org.springframework.stereotype.Repository;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 <% if (databaseType === 'cassandra') { %>
 import com.datastax.driver.core.*;
 import com.datastax.driver.mapping.Mapper;
@@ -79,7 +81,13 @@ public interface <%=entityClass%>Repository extends <% if (databaseType === 'sql
     List<<%= entityClass %>> findBy<%= relationships[idx].relationshipNameCapitalized %>IsCurrentUser();
     <%_ } } _%>
     <%_ if (fieldsContainOwnerManyToMany === true) { _%>
-    @Query("select distinct <%= entityTableName %> from <%= entityClass %> <%= entityTableName %><% for (idx in relationships) {
+
+    @Query(value = "select distinct <%= entityTableName %> from <%= entityClass %> <%= entityTableName %><% for (idx in relationships) {
+    if (relationships[idx].relationshipType === 'many-to-many' && relationships[idx].ownerSide === true) { %> left join fetch <%=entityTableName%>.<%=relationships[idx].relationshipFieldNamePlural%><%} }%>",
+        countQuery = "select count(distinct <%= entityTableName %>) from <%= entityClass %> <%= entityTableName %>")
+    Page<<%=entityClass%>> findAllWithEagerRelationships(Pageable pageable);
+
+    @Query(value = "select distinct <%= entityTableName %> from <%= entityClass %> <%= entityTableName %><% for (idx in relationships) {
     if (relationships[idx].relationshipType === 'many-to-many' && relationships[idx].ownerSide === true) { %> left join fetch <%=entityTableName%>.<%=relationships[idx].relationshipFieldNamePlural%><%} }%>")
     List<<%=entityClass%>> findAllWithEagerRelationships();
 
diff --git a/generators/entity-server/templates/src/main/java/package/service/_EntityService.java b/generators/entity-server/templates/src/main/java/package/service/_EntityService.java
index 8eab34cad4..098d0cc97f 100644
--- a/generators/entity-server/templates/src/main/java/package/service/_EntityService.java
+++ b/generators/entity-server/templates/src/main/java/package/service/_EntityService.java
@@ -24,7 +24,7 @@ import <%=packageName%>.service.dto.<%= entityClass %>DTO;
 <%_ } else { _%>
 import <%=packageName%>.domain.<%= entityClass %>;
 <%_ } _%>
-<%_ if (pagination !== 'no') { _%>
+<%_ if (pagination !== 'no' || fieldsContainOwnerManyToMany === true) { _%>
 
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
@@ -64,6 +64,15 @@ public interface <%= entityClass %>Service {
     List<<%= instanceType %>> findAllWhere<%= relationships[idx].relationshipNameCapitalized %>IsNull();
 <% } } -%>
 
+    <%_ if (fieldsContainOwnerManyToMany === true) { _%>
+    /**
+     * Get all the <%= entityClass %> with eager load of many-to-many relationships.
+     *
+     * @return the list of entities
+     */
+    Page<<%= instanceType %>> findAllWithEagerRelationships(Pageable pageable);
+    <% } -%>
+
     /**
      * Get the "id" <%= entityInstance %>.
      *
diff --git a/generators/entity-server/templates/src/main/java/package/service/impl/_EntityServiceImpl.java b/generators/entity-server/templates/src/main/java/package/service/impl/_EntityServiceImpl.java
index a65dab1733..ffbaea3916 100644
--- a/generators/entity-server/templates/src/main/java/package/service/impl/_EntityServiceImpl.java
+++ b/generators/entity-server/templates/src/main/java/package/service/impl/_EntityServiceImpl.java
@@ -36,10 +36,8 @@ import <%=packageName%>.service.dto.<%= entityClass %>DTO;
 import <%=packageName%>.service.mapper.<%= entityClass %>Mapper;<% } %>
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-<%_ if (pagination !== 'no') { _%>
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
-<%_ } _%>
 import org.springframework.stereotype.Service;
 <%_ if (databaseType === 'sql') { _%>
 import org.springframework.transaction.annotation.Transactional;
@@ -102,6 +100,17 @@ public class <%= serviceClassName %><% if (service === 'serviceImpl') { %> imple
             .map(<%= entityToDtoReference %>);<% } %>
         <%_ } _%>
     }
+    <%_ if (fieldsContainOwnerManyToMany === true) { _%>
+
+    /**
+     * Get all the <%= entityClass %> with eager load of many-to-many relationships.
+     *
+     * @return the list of entities
+     */
+    public Page<<%= instanceType %>> findAllWithEagerRelationships(Pageable pageable) {
+        return <%= entityInstance %>Repository.findAllWithEagerRelationships(pageable)<% if (dto !== 'mapstruct') { %>;<% } else { %>.map(<%= entityToDtoReference %>);<% } %>
+    }
+    <% } %>
 <%- include('../../common/get_filtered_template'); -%>
     /**
      * Get one <%= entityInstance %> by id.
diff --git a/generators/entity-server/templates/src/main/java/package/web/rest/_EntityResource.java b/generators/entity-server/templates/src/main/java/package/web/rest/_EntityResource.java
index c9baa2150e..6e98539ead 100644
--- a/generators/entity-server/templates/src/main/java/package/web/rest/_EntityResource.java
+++ b/generators/entity-server/templates/src/main/java/package/web/rest/_EntityResource.java
@@ -126,7 +126,8 @@ public class <%= entityClass %>Resource {
     /**
      * GET  /<%= entityApiUrl %> : get all the <%= entityInstancePlural %>.
      *<% if (pagination !== 'no') { %>
-     * @param pageable the pagination information<% } if (jpaMetamodelFiltering) { %>
+     * @param pageable the pagination information<% } if (!jpaMetamodelFiltering && fieldsContainOwnerManyToMany) { %>
+     * @param eagerload flag to eager load entities from relationships (This is applicable for many-to-many)<% } if (jpaMetamodelFiltering) { %>
      * @param criteria the criterias which the requested entities should match<% } else if (fieldsContainNoOwnerOneToOne) { %>
      * @param filter the filter of the request<% } %>
      * @return the ResponseEntity with status 200 (OK) and the list of <%= entityInstancePlural %> in body
diff --git a/generators/entity/index.js b/generators/entity/index.js
index 485aa74e69..c174bfb4eb 100644
--- a/generators/entity/index.js
+++ b/generators/entity/index.js
@@ -680,7 +680,7 @@ module.exports = class extends BaseGenerator {
                             }
                         } else {
                             relationship.otherEntityModuleName = `${context.angularXAppName}SharedModule`;
-                            relationship.otherEntityModulePath = 'app/shared';
+                            relationship.otherEntityModulePath = 'app/core';
                         }
                     }
                     // Load in-memory data for root
diff --git a/generators/generator-base-private.js b/generators/generator-base-private.js
index 43b4de3500..52dfd03955 100644
--- a/generators/generator-base-private.js
+++ b/generators/generator-base-private.js
@@ -176,7 +176,7 @@ module.exports = class extends Generator {
      * @param languages
      */
     updateLanguagesInLanguageConstantNG2(languages) {
-        const fullPath = `${CLIENT_MAIN_SRC_DIR}app/shared/language/language.constants.ts`;
+        const fullPath = `${CLIENT_MAIN_SRC_DIR}app/core/language/language.constants.ts`;
         try {
             let content = 'export const LANGUAGES: string[] = [\n';
             languages.forEach((language, i) => {
diff --git a/generators/generator-constants.js b/generators/generator-constants.js
index f303fc5cbc..4f94db8e5d 100644
--- a/generators/generator-constants.js
+++ b/generators/generator-constants.js
@@ -41,7 +41,7 @@ const DOCKER_JHIPSTER_LOGSTASH = 'jhipster/jhipster-logstash:v3.0.1';
 const DOCKER_JHIPSTER_IMPORT_DASHBOARDS = 'jhipster/jhipster-import-dashboards:v3.0.1';
 const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v3.0.1';
 const DOCKER_TRAEFIK = 'traefik:1.4';
-const DOCKER_CONSUL = 'consul:0.9.3';
+const DOCKER_CONSUL = 'consul:1.0.2';
 const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.2.2';
 const DOCKER_PROMETHEUS = 'prom/prometheus:v1.6.3';
 const DOCKER_PROMETHEUS_ALERTMANAGER = 'prom/alertmanager:v0.6.2';
diff --git a/generators/server/templates/_build.gradle b/generators/server/templates/_build.gradle
index 354b2611a2..36e1af5368 100644
--- a/generators/server/templates/_build.gradle
+++ b/generators/server/templates/_build.gradle
@@ -289,7 +289,9 @@ dependencies {
     compile "org.springframework.boot:spring-boot-loader-tools"
     compile "org.springframework.boot:spring-boot-starter-mail"
     compile "org.springframework.boot:spring-boot-starter-logging"
-    compile "org.springframework.boot:spring-boot-starter-actuator"
+    compile ("org.springframework.boot:spring-boot-starter-actuator") {
+        exclude module: 'micrometer-core'
+    }
     compile "org.springframework.boot:spring-boot-starter-aop"
     <%_ if (databaseType === 'sql') { _%>
     compile "org.springframework.boot:spring-boot-starter-data-jpa"
diff --git a/generators/server/templates/_pom.xml b/generators/server/templates/_pom.xml
index 955bfda1bc..98fc7dc856 100644
--- a/generators/server/templates/_pom.xml
+++ b/generators/server/templates/_pom.xml
@@ -484,6 +484,12 @@
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-actuator</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>io.micrometer</groupId>
+                    <artifactId>micrometer-core</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
diff --git a/generators/server/templates/gitignore b/generators/server/templates/gitignore
index b7bdc5ff29..9b69ace8c2 100644
--- a/generators/server/templates/gitignore
+++ b/generators/server/templates/gitignore
@@ -61,6 +61,7 @@ local.properties
 *.ids
 *.orig
 classes/
+out/
 
 ######################
 # Visual Studio Code
diff --git a/generators/server/templates/src/main/docker/_app.yml b/generators/server/templates/src/main/docker/_app.yml
index 096ae32077..f4793febfd 100644
--- a/generators/server/templates/src/main/docker/_app.yml
+++ b/generators/server/templates/src/main/docker/_app.yml
@@ -57,10 +57,12 @@ services:
             # For keycloak to work, you need to add '127.0.0.1 keycloak' to your hosts file
             - SECURITY_OAUTH2_CLIENT_ACCESS_TOKEN_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/token
             - SECURITY_OAUTH2_CLIENT_USER_AUTHORIZATION_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/auth
+            - SECURITY_OAUTH2_CLIENT_CLIENT_ID=<% if (applicationType === 'microservice') { %>internal<% } else { %>web_app<% } %>
+            - SECURITY_OAUTH2_CLIENT_CLIENT_SECRET=<% if (applicationType === 'microservice') { %>internal<% } else { %>web_app<% } %>
             - SECURITY_OAUTH2_RESOURCE_USER_INFO_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/userinfo
             - SECURITY_OAUTH2_RESOURCE_TOKEN_INFO_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/token/introspect
                 <%_ if (applicationType === 'gateway' || applicationType === 'microservice') { _%>
-            - SECURITY_OAUTH2_RESOURCE_JWT_KEY_URI=http://keycloak:9080/auth/realms/jhipster
+            - SECURITY_OAUTH2_RESOURCE_JWK_KEY_SET_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/certs
                 <%_ } _%>
             <%_ } _%>
             <%_ if (prodDatabaseType === 'cassandra') { _%>
diff --git a/generators/server/templates/src/main/docker/_jhipster-registry.yml b/generators/server/templates/src/main/docker/_jhipster-registry.yml
index 6d0f1f0c19..01b19c851a 100644
--- a/generators/server/templates/src/main/docker/_jhipster-registry.yml
+++ b/generators/server/templates/src/main/docker/_jhipster-registry.yml
@@ -37,9 +37,11 @@ services:
             # For keycloak to work, you need to add '127.0.0.1 keycloak' to your hosts file
             - SECURITY_OAUTH2_CLIENT_ACCESS_TOKEN_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/token
             - SECURITY_OAUTH2_CLIENT_USER_AUTHORIZATION_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/auth
+            - SECURITY_OAUTH2_CLIENT_CLIENT_ID=web_app
+            - SECURITY_OAUTH2_CLIENT_CLIENT_SECRET=web_app
             - SECURITY_OAUTH2_RESOURCE_USER_INFO_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/userinfo
             - SECURITY_OAUTH2_RESOURCE_TOKEN_INFO_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/token/introspect
-            - SECURITY_OAUTH2_RESOURCE_JWT_KEY_URI=http://keycloak:9080/auth/realms/jhipster
+            - SECURITY_OAUTH2_RESOURCE_JWK_KEY_SET_URI=http://keycloak:9080/auth/realms/jhipster/protocol/openid-connect/certs
             <%_ } _%>
         ports:
             - 8761:8761
diff --git a/generators/server/templates/src/main/java/package/config/_MicroserviceSecurityConfiguration.java b/generators/server/templates/src/main/java/package/config/_MicroserviceSecurityConfiguration.java
index e21ba11259..0234e651e4 100644
--- a/generators/server/templates/src/main/java/package/config/_MicroserviceSecurityConfiguration.java
+++ b/generators/server/templates/src/main/java/package/config/_MicroserviceSecurityConfiguration.java
@@ -197,30 +197,19 @@ import <%=packageName%>.security.oauth2.*;
 <%_ if(applicationType === 'gateway') { _%>
 import org.springframework.beans.factory.annotation.Qualifier;
 <%_ } _%>
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.autoconfigure.security.oauth2.resource.*;
 import org.springframework.context.annotation.*;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
 import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
 import org.springframework.security.config.http.SessionCreationPolicy;
 import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
 import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
-import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
 <%_ if(applicationType === 'gateway') { _%>
 import org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher;
 import org.springframework.security.web.util.matcher.RequestMatcher;
 <%_ } _%>
-import org.springframework.web.client.RestTemplate;
 import org.zalando.problem.spring.web.advice.security.SecurityProblemSupport;
 
-import java.util.Map;
-import java.util.Optional;
-
 @Configuration
 @Import(SecurityProblemSupport.class)
 @EnableResourceServer
@@ -299,34 +288,5 @@ public class MicroserviceSecurityConfiguration extends ResourceServerConfigurerA
             .antMatchers("/management/health").permitAll()
             .antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN);
     }
-
-    @Bean
-    @ConditionalOnProperty("security.oauth2.resource.jwt.key-uri")
-    public TokenStore tokenStore(JwtAccessTokenConverter jwtAccessTokenConverter) {
-        return new JwtTokenStore(jwtAccessTokenConverter);
-    }
-
-    @Bean
-    @ConditionalOnProperty("security.oauth2.resource.jwt.key-uri")
-    public JwtAccessTokenConverter jwtAccessTokenConverter() {
-        JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
-        converter.setVerifierKey(getKeyFromAuthorizationServer());
-        return converter;
-    }
-
-    private String getKeyFromAuthorizationServer() {
-        return Optional.ofNullable(
-            new RestTemplate()
-                .exchange(
-                    resourceServerProperties.getJwt().getKeyUri(),
-                    HttpMethod.GET,
-                    new HttpEntity<Void>(new HttpHeaders()),
-                    Map.class
-                )
-                .getBody()
-                .get("public_key"))
-            .map(publicKey -> String.format("-----BEGIN PUBLIC KEY-----\n%s\n-----END PUBLIC KEY-----", publicKey))
-            .orElse(resourceServerProperties.getJwt().getKeyValue());
-    }
 }
 <%_ } _%>
diff --git a/generators/server/templates/src/main/java/package/service/_UserService.java b/generators/server/templates/src/main/java/package/service/_UserService.java
index 401d67f8ab..00a03fadd0 100644
--- a/generators/server/templates/src/main/java/package/service/_UserService.java
+++ b/generators/server/templates/src/main/java/package/service/_UserService.java
@@ -158,8 +158,7 @@ public class UserService {
                 userSearchRepository.save(user);
                 <%_ } _%>
                 <%_ if (cacheManagerIsAvailable === true) { _%>
-                cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
-                cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
+                this.clearUserCaches(user);
                 <%_ } _%>
                 log.debug("Activated user: {}", user);
                 return user;
@@ -179,8 +178,7 @@ public class UserService {
                 userRepository.save(user);
                 <%_ } _%>
                 <%_ if (cacheManagerIsAvailable === true) { _%>
-                cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
-                cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
+                this.clearUserCaches(user);
                 <%_ } _%>
                 return user;
            });
@@ -196,8 +194,7 @@ public class UserService {
                 userRepository.save(user);
                 <%_ } _%>
                 <%_ if (cacheManagerIsAvailable === true) { _%>
-                cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
-                cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
+                this.clearUserCaches(user);
                 <%_ } _%>
                 return user;
             });
@@ -205,9 +202,7 @@ public class UserService {
 
     public User registerUser(UserDTO userDTO, String password) {
 
-        User newUser = new User();<% if (databaseType === 'sql' || databaseType === 'mongodb') { %>
-        Authority authority = authorityRepository.findById(AuthoritiesConstants.USER).get();
-        Set<Authority> authorities = new HashSet<>();<% } %><% if (databaseType === 'cassandra') { %>
+        User newUser = new User();<% if (databaseType === 'cassandra') { %>
         newUser.setId(UUID.randomUUID().toString());<% } %><% if (databaseType === 'cassandra' || databaseType === 'couchbase') { %>
         Set<String> authorities = new HashSet<>();<% } %>
         String encryptedPassword = passwordEncoder.encode(password);
@@ -226,7 +221,8 @@ public class UserService {
         // new user gets registration key
         newUser.setActivationKey(RandomUtil.generateActivationKey());
         <%_ if (databaseType === 'sql' || databaseType === 'mongodb') { _%>
-        authorities.add(authority);
+        Set<Authority> authorities = new HashSet<>();
+        authorityRepository.findById(AuthoritiesConstants.USER).ifPresent(authorities::add);
         <%_ } _%>
         <%_ if (databaseType === 'cassandra' || databaseType === 'couchbase') { _%>
         authorities.add(AuthoritiesConstants.USER);
@@ -235,8 +231,7 @@ public class UserService {
         userRepository.save(newUser);<% if (searchEngine === 'elasticsearch') { %>
         userSearchRepository.save(newUser);<% } %>
         <%_ if (cacheManagerIsAvailable === true) { _%>
-        cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(newUser.getLogin());
-        cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(newUser.getEmail());
+        this.clearUserCaches(newUser);
         <%_ } _%>
         log.debug("Created Information for User: {}", newUser);
         return newUser;
@@ -278,8 +273,7 @@ public class UserService {
         userRepository.save(user);<% if (searchEngine === 'elasticsearch') { %>
         userSearchRepository.save(user);<% } %>
         <%_ if (cacheManagerIsAvailable === true) { _%>
-        cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
-        cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
+        this.clearUserCaches(user);
         <%_ } _%>
         log.debug("Created Information for User: {}", user);
         return user;
@@ -301,9 +295,6 @@ public class UserService {
         SecurityUtils.getCurrentUserLogin()
             .flatMap(userRepository::findOneByLogin)
             .ifPresent(user -> {
-                <%_ if (cacheManagerIsAvailable === true) { _%>
-                cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
-                <%_ } _%>
                 user.setFirstName(firstName);
                 user.setLastName(lastName);
                 user.setEmail(email);
@@ -318,8 +309,7 @@ public class UserService {
                 userSearchRepository.save(user);
                 <%_ } _%>
                 <%_ if (cacheManagerIsAvailable === true) { _%>
-                cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
-                cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
+                this.clearUserCaches(user);
                 <%_ } _%>
                 log.debug("Changed Information for User: {}", user);
             });
@@ -343,8 +333,7 @@ public class UserService {
                 }
                 <%_ } _%>
                 <%_ if (cacheManagerIsAvailable === true) { _%>
-                cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
-                cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
+                this.clearUserCaches(user);
                 <%_ } _%>
                 user.setLogin(userDTO.getLogin());
                 user.setFirstName(userDTO.getFirstName());
@@ -373,8 +362,7 @@ public class UserService {
                 userSearchRepository.save(user);
                 <%_ } _%>
                 <%_ if (cacheManagerIsAvailable === true) { _%>
-                cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
-                cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
+                this.clearUserCaches(user);
                 <%_ } _%>
                 log.debug("Changed Information for User: {}", user);
                 return user;
@@ -392,8 +380,7 @@ public class UserService {
             userSearchRepository.delete(user);
             <%_ } _%>
             <%_ if (cacheManagerIsAvailable === true) { _%>
-            cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
-            cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
+            this.clearUserCaches(user);
             <%_ } _%>
             log.debug("Deleted User: {}", user);
         });
@@ -412,8 +399,7 @@ public class UserService {
                 userRepository.save(user);
                 <%_ } _%>
                 <%_ if (cacheManagerIsAvailable === true) { _%>
-                cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
-                cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
+                this.clearUserCaches(user);
                 <%_ } _%>
                 log.debug("Changed password for User: {}", user);
             });
@@ -504,8 +490,7 @@ public class UserService {
             userSearchRepository.delete(user);
             <%_ } _%>
             <%_ if (cacheManagerIsAvailable === true) { _%>
-            cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
-            cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
+            this.clearUserCaches(user);
             <%_ } _%>
         }
     }
@@ -571,8 +556,7 @@ public class UserService {
             log.debug("Saving user '{}' in local database...", user.getLogin());
             userRepository.save(user);
             <%_ if (cacheManagerIsAvailable === true) { _%>
-            cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
-            cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
+            this.clearUserCaches(user);
             <%_ } _%>
         }
         return user;
@@ -650,5 +634,11 @@ public class UserService {
                     })<% } %>.collect(Collectors.toSet());
     }
     <%_ } _%>
+    <%_ if (cacheManagerIsAvailable === true) { _%>
 
+    private void clearUserCaches(User user) {
+        Objects.requireNonNull(cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE)).evict(user.getLogin());
+        Objects.requireNonNull(cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE)).evict(user.getEmail());
+    }
+    <%_ } _%>
 }
diff --git a/generators/server/templates/src/main/java/package/web/rest/_AuthResource.java b/generators/server/templates/src/main/java/package/web/rest/_AuthResource.java
index d56dff4638..0aeb66ea79 100755
--- a/generators/server/templates/src/main/java/package/web/rest/_AuthResource.java
+++ b/generators/server/templates/src/main/java/package/web/rest/_AuthResource.java
@@ -81,6 +81,6 @@ public class AuthResource {
     public ResponseEntity<?> logout(HttpServletRequest request, HttpServletResponse response) {
         log.info("logging out user {}", SecurityContextHolder.getContext().getAuthentication().getName());
         authenticationService.logout(request, response);
-        return ResponseEntity.ok(null);
+        return ResponseEntity.noContent().build();
     }
 }
diff --git a/generators/server/templates/src/main/resources/config/_application.yml b/generators/server/templates/src/main/resources/config/_application.yml
index 7478fb2760..7642835464 100644
--- a/generators/server/templates/src/main/resources/config/_application.yml
+++ b/generators/server/templates/src/main/resources/config/_application.yml
@@ -222,8 +222,8 @@ security:
             token-info-uri: http://localhost:9080/auth/realms/jhipster/protocol/openid-connect/token/introspect
             prefer-token-info: false
             <%_ if (applicationType === 'gateway' || applicationType === 'microservice') {  _%>
-            jwt:
-                key-uri: http://localhost:9080/auth/realms/jhipster
+            jwk:
+                key-set-uri: http://localhost:9080/auth/realms/jhipster/protocol/openid-connect/certs
             <%_ } _%>
     <%_ } _%>
 


Test patch:
diff --git a/generators/client/templates/angular/src/test/javascript/spec/_test.module.ts b/generators/client/templates/angular/src/test/javascript/spec/_test.module.ts
index 6a0db4b27c..073a60c884 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/_test.module.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/_test.module.ts
@@ -25,11 +25,11 @@ import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
 import { JhiLanguageService, JhiDataUtils, JhiDateUtils, JhiEventManager, JhiAlertService, JhiParseLinks } from 'ng-jhipster';
 
 import { MockLanguageService, MockLanguageHelper } from './helpers/mock-language.service';
-import { JhiLanguageHelper, Principal, AccountService<% if (authenticationType !== 'oauth2') { %>, LoginModalService<% } %><% if (websocket === 'spring-websocket') { %>, <%=jhiPrefixCapitalized%>TrackerService<% } %> } from 'app/shared';
+import { JhiLanguageHelper, Principal, AccountService<% if (authenticationType !== 'oauth2') { %>, LoginModalService<% } %><% if (websocket === 'spring-websocket') { %>, <%=jhiPrefixCapitalized%>TrackerService<% } %> } from 'app/core';
 <%_ } else { _%>
 import { JhiDataUtils, JhiDateUtils, JhiEventManager, JhiAlertService, JhiParseLinks } from 'ng-jhipster';
 
-import { Principal, AccountService<% if (authenticationType !== 'oauth2') { %>, LoginModalService<% } %><% if (websocket === 'spring-websocket') { %>, JhiTrackerService<% } %> } from 'app/shared';
+import { Principal, AccountService<% if (authenticationType !== 'oauth2') { %>, LoginModalService<% } %><% if (websocket === 'spring-websocket') { %>, JhiTrackerService<% } %> } from 'app/core';
 <%_ } _%>
 import { MockPrincipal } from './helpers/mock-principal.service';
 import { MockAccountService } from './helpers/mock-account.service';
diff --git a/generators/client/templates/angular/src/test/javascript/spec/app/account/password-reset/init/_password-reset-init.component.spec.ts b/generators/client/templates/angular/src/test/javascript/spec/app/account/password-reset/init/_password-reset-init.component.spec.ts
index eaf690b7d1..314335a097 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/app/account/password-reset/init/_password-reset-init.component.spec.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/app/account/password-reset/init/_password-reset-init.component.spec.ts
@@ -98,9 +98,7 @@ describe('Component Tests', () => {
             inject([PasswordResetInitService], (service: PasswordResetInitService) => {
                 spyOn(service, 'save').and.returnValue(Observable.throw({
                     status: 400,
-                    json() {
-                        return {type : EMAIL_NOT_FOUND_TYPE};
-                    }
+                    error : {type : EMAIL_NOT_FOUND_TYPE }
                 }));
                 comp.resetAccount.email = 'user@domain.com';
 
diff --git a/generators/client/templates/angular/src/test/javascript/spec/app/account/password/_password.component.spec.ts b/generators/client/templates/angular/src/test/javascript/spec/app/account/password/_password.component.spec.ts
index c959fa468b..f68ae19eb4 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/app/account/password/_password.component.spec.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/app/account/password/_password.component.spec.ts
@@ -23,10 +23,10 @@ import { Observable } from 'rxjs/Observable';
 import { <%=angularXAppName%>TestModule } from '../../../test.module';
 import { PasswordComponent } from 'app/account/password/password.component';
 import { PasswordService } from 'app/account/password/password.service';
-import { Principal } from 'app/shared/auth/principal.service';
-import { AccountService } from 'app/shared/auth/account.service';
+import { Principal } from 'app/core/auth/principal.service';
+import { AccountService } from 'app/core/auth/account.service';
 <%_ if (websocket === 'spring-websocket') { _%>
-import { <%=jhiPrefixCapitalized%>TrackerService } from 'app/shared/tracker/tracker.service';
+import { <%=jhiPrefixCapitalized%>TrackerService } from 'app/core/tracker/tracker.service';
 import { MockTrackerService } from '../../../helpers/mock-tracker.service';
 <%_ } _%>
 
diff --git a/generators/client/templates/angular/src/test/javascript/spec/app/account/sessions/_sessions.component.spec.ts b/generators/client/templates/angular/src/test/javascript/spec/app/account/sessions/_sessions.component.spec.ts
index efc52a7e60..95bb93f674 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/app/account/sessions/_sessions.component.spec.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/app/account/sessions/_sessions.component.spec.ts
@@ -24,7 +24,7 @@ import { Session } from 'app/account/sessions/session.model';
 import { SessionsComponent } from 'app/account/sessions/sessions.component';
 import { SessionsService } from 'app/account/sessions/sessions.service';
 import { MockPrincipal } from '../../../helpers/mock-principal.service';
-import { Principal } from 'app/shared/auth/principal.service';
+import { Principal } from 'app/core/auth/principal.service';
 
 describe('Component Tests', () => {
 
diff --git a/generators/client/templates/angular/src/test/javascript/spec/app/account/settings/_settings.component.spec.ts b/generators/client/templates/angular/src/test/javascript/spec/app/account/settings/_settings.component.spec.ts
index 236387b7b0..e29ed5d16e 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/app/account/settings/_settings.component.spec.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/app/account/settings/_settings.component.spec.ts
@@ -20,10 +20,10 @@ import { ComponentFixture, TestBed, async } from '@angular/core/testing';
 import { Observable } from 'rxjs/Observable';
 
 import { <%=angularXAppName%>TestModule } from '../../../test.module';
-import { Principal, AccountService } from 'app/shared';
+import { Principal, AccountService } from 'app/core';
 import { SettingsComponent } from 'app/account/settings/settings.component';
 <%_ if (websocket === 'spring-websocket') { _%>
-import { <%=jhiPrefixCapitalized%>TrackerService } from 'app/shared/tracker/tracker.service';
+import { <%=jhiPrefixCapitalized%>TrackerService } from 'app/core/tracker/tracker.service';
 import { MockTrackerService } from '../../../helpers/mock-tracker.service';
 <%_ } _%>
 
diff --git a/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management-delete-dialog.component.spec.ts b/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management-delete-dialog.component.spec.ts
index ee66fa96b6..ef1541cd7d 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management-delete-dialog.component.spec.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management-delete-dialog.component.spec.ts
@@ -23,7 +23,7 @@ import { JhiEventManager } from 'ng-jhipster';
 
 import { <%=angularXAppName%>TestModule } from '../../../test.module';
 import { UserMgmtDeleteDialogComponent } from 'app/admin/user-management/user-management-delete-dialog.component';
-import { UserService } from 'app/shared';
+import { UserService } from 'app/core';
 
 describe('Component Tests', () => {
 
diff --git a/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management-detail.component.spec.ts b/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management-detail.component.spec.ts
index 3b389c01b1..38ae85eb56 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management-detail.component.spec.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management-detail.component.spec.ts
@@ -6,7 +6,7 @@ import { Observable } from 'rxjs/Observable';
 import { <%=angularXAppName%>TestModule } from '../../../test.module';
 import { MockActivatedRoute } from '../../../helpers/mock-route.service';
 import { UserMgmtDetailComponent } from 'app/admin/user-management/user-management-detail.component';
-import { UserService, User } from 'app/shared';
+import { UserService, User } from 'app/core';
 
 describe('Component Tests', () => {
 
diff --git a/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management-dialog.component.spec.ts b/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management-dialog.component.spec.ts
index 84d544d716..411c2a67b2 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management-dialog.component.spec.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management-dialog.component.spec.ts
@@ -27,7 +27,7 @@ import { JhiEventManager } from 'ng-jhipster';
 
 import { <%=angularXAppName%>TestModule } from '../../../test.module';
 import { UserMgmtDialogComponent } from 'app/admin/user-management/user-management-dialog.component';
-import { UserService, User<% if(enableTranslation) { %>, JhiLanguageHelper<% } %> } from 'app/shared';
+import { UserService, User<% if(enableTranslation) { %>, JhiLanguageHelper<% } %> } from 'app/core';
 
 describe('Component Tests', () => {
 
diff --git a/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management.component.spec.ts b/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management.component.spec.ts
index 78e4fa4c2e..74d6caa8af 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management.component.spec.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/app/admin/user-management/_user-management.component.spec.ts
@@ -25,7 +25,7 @@ import { HttpHeaders, HttpResponse } from '@angular/common/http';
 
 import { <%=angularXAppName%>TestModule } from '../../../test.module';
 import { UserMgmtComponent } from 'app/admin/user-management/user-management.component';
-import { UserService, User } from 'app/shared';
+import { UserService, User } from 'app/core';
 
 describe('Component Tests', () => {
 
diff --git a/generators/client/templates/angular/src/test/javascript/spec/app/shared/user/_user.service.spec.ts b/generators/client/templates/angular/src/test/javascript/spec/app/core/user/_user.service.spec.ts
similarity index 98%
rename from generators/client/templates/angular/src/test/javascript/spec/app/shared/user/_user.service.spec.ts
rename to generators/client/templates/angular/src/test/javascript/spec/app/core/user/_user.service.spec.ts
index d1e469930d..27cd0babe5 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/app/shared/user/_user.service.spec.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/app/core/user/_user.service.spec.ts
@@ -19,7 +19,7 @@ limitations under the License.
 import { TestBed } from '@angular/core/testing';
 import { JhiDateUtils } from 'ng-jhipster';
 
-import { UserService, User } from 'app/shared';
+import { UserService, User } from 'app/core';
 import { SERVER_API_URL } from 'app/app.constants';
 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
 
diff --git a/generators/client/templates/angular/src/test/javascript/spec/app/shared/login/_login.component.spec.ts b/generators/client/templates/angular/src/test/javascript/spec/app/shared/login/_login.component.spec.ts
index b1e8ee2e07..2fb800aac0 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/app/shared/login/_login.component.spec.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/app/shared/login/_login.component.spec.ts
@@ -21,9 +21,9 @@ import { Router } from '@angular/router';
 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
 import { JhiEventManager } from 'ng-jhipster';
 
-import { LoginService } from 'app/shared/login/login.service';
+import { LoginService } from 'app/core/login/login.service';
 import { <%=jhiPrefixCapitalized%>LoginModalComponent } from 'app/shared/login/login.component';
-import { StateStorageService } from 'app/shared/auth/state-storage.service';
+import { StateStorageService } from 'app/core/auth/state-storage.service';
 import { <%=angularXAppName%>TestModule } from '../../../test.module';
 import { MockLoginService } from '../../../helpers/mock-login.service';
 import { MockStateStorageService } from '../../../helpers/mock-state-storage.service';
diff --git a/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-account.service.ts b/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-account.service.ts
index c9f26d7b30..f82c71cb96 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-account.service.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-account.service.ts
@@ -17,7 +17,7 @@
  limitations under the License.
 -%>
 import { SpyObject } from './spyobject';
-import { AccountService } from 'app/shared/auth/account.service';
+import { AccountService } from 'app/core/auth/account.service';
 import Spy = jasmine.Spy;
 
 export class MockAccountService extends SpyObject {
diff --git a/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-language.service.ts b/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-language.service.ts
index 3e9989394b..cdacb3ac64 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-language.service.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-language.service.ts
@@ -18,7 +18,7 @@
 -%>
 import { SpyObject } from './spyobject';
 import { JhiLanguageService } from 'ng-jhipster';
-import { JhiLanguageHelper } from 'app/shared/language/language.helper';
+import { JhiLanguageHelper } from 'app/core/language/language.helper';
 import Spy = jasmine.Spy;
 
 export class MockLanguageService extends SpyObject {
diff --git a/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-login.service.ts b/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-login.service.ts
index 9b738072d2..6c0802d670 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-login.service.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-login.service.ts
@@ -17,7 +17,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 -%>
 import { SpyObject } from './spyobject';
-import { LoginService } from 'app/shared/login/login.service';
+import { LoginService } from 'app/core/login/login.service';
 import Spy = jasmine.Spy;
 
 export class MockLoginService extends SpyObject {
diff --git a/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-principal.service.ts b/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-principal.service.ts
index a838afb410..895f914bca 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-principal.service.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-principal.service.ts
@@ -17,7 +17,7 @@
  limitations under the License.
 -%>
 import { SpyObject } from './spyobject';
-import { Principal } from 'app/shared/auth/principal.service';
+import { Principal } from 'app/core/auth/principal.service';
 import Spy = jasmine.Spy;
 
 export class MockPrincipal extends SpyObject {
diff --git a/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-state-storage.service.ts b/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-state-storage.service.ts
index fbd293504a..dbac863c51 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-state-storage.service.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-state-storage.service.ts
@@ -17,7 +17,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 -%>
 import { SpyObject } from './spyobject';
-import { StateStorageService } from 'app/shared/auth/state-storage.service';
+import { StateStorageService } from 'app/core/auth/state-storage.service';
 import Spy = jasmine.Spy;
 
 export class MockStateStorageService extends SpyObject {
diff --git a/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-tracker.service.ts b/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-tracker.service.ts
index bed4ffbe74..0e8e0630da 100644
--- a/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-tracker.service.ts
+++ b/generators/client/templates/angular/src/test/javascript/spec/helpers/_mock-tracker.service.ts
@@ -17,7 +17,7 @@
  limitations under the License.
 -%>
 import { SpyObject } from './spyobject';
-import { <%=jhiPrefixCapitalized%>TrackerService } from 'app/shared/tracker/tracker.service';
+import { <%=jhiPrefixCapitalized%>TrackerService } from 'app/core/tracker/tracker.service';
 
 export class MockTrackerService extends SpyObject {
 
diff --git a/generators/entity-client/templates/angular/src/test/javascript/spec/app/entities/_entity-management-dialog.component.spec.ts b/generators/entity-client/templates/angular/src/test/javascript/spec/app/entities/_entity-management-dialog.component.spec.ts
index 592d61dfc3..9c7f260c91 100644
--- a/generators/entity-client/templates/angular/src/test/javascript/spec/app/entities/_entity-management-dialog.component.spec.ts
+++ b/generators/entity-client/templates/angular/src/test/javascript/spec/app/entities/_entity-management-dialog.component.spec.ts
@@ -45,7 +45,7 @@ Object.keys(differentRelationships).forEach(key => {
         const uniqueRel = differentRelationships[key][0];
         if (uniqueRel.otherEntityAngularName !== entityAngularName) {
             const modulePath = uniqueRel.otherEntityAngularName === 'User' ?
-                `app/shared`
+                `app/core`
                 : `app/entities/${uniqueRel.otherEntityClientRootFolder ? `${uniqueRel.otherEntityClientRootFolder}/` : ''}${uniqueRel.otherEntityFileName}`
 _%>
 import { <%= uniqueRel.otherEntityAngularName%>Service } from '<%= modulePath %>';
diff --git a/generators/entity-server/templates/src/test/java/package/web/rest/_EntityResourceIntTest.java b/generators/entity-server/templates/src/test/java/package/web/rest/_EntityResourceIntTest.java
index 978a0aa51c..afcd162493 100644
--- a/generators/entity-server/templates/src/test/java/package/web/rest/_EntityResourceIntTest.java
+++ b/generators/entity-server/templates/src/test/java/package/web/rest/_EntityResourceIntTest.java
@@ -44,10 +44,11 @@ import <%=packageName%>.service.<%= entityClass %>QueryService;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
-<%_ if (searchEngine === 'elasticsearch' && pagination !== 'no') { _%>
+<%_ if (searchEngine === 'elasticsearch' && pagination !== 'no' || fieldsContainOwnerManyToMany) { _%>
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 <%_ } _%>
@@ -72,7 +73,8 @@ import java.time.temporal.ChronoUnit;<% } %>
 <%_ if (searchEngine === 'elasticsearch') { _%>
 import java.util.Collections;
 <%_ } _%>
-import java.util.List;<% if (databaseType === 'cassandra') { %>
+import java.util.List;
+import java.util.ArrayList;<% if (databaseType === 'cassandra') { %>
 import java.util.UUID;<% } %>
 <%_ if (databaseType === 'couchbase') { _%>
     import static <%= packageName %>.web.rest.TestUtil.mockAuthentication;
@@ -85,7 +87,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
 <%_ } _%>
 import static org.hamcrest.Matchers.hasItem;
-<%_ if (searchEngine === 'elasticsearch') { _%>
+<%_ if (searchEngine === 'elasticsearch' || fieldsContainOwnerManyToMany === true) { _%>
 import static org.mockito.Mockito.*;
 <%_ } _%>
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
@@ -263,10 +265,17 @@ _%>
     <%_ } } _%>
 
     @Autowired
-    private <%= entityClass %>Repository <%= entityInstance %>Repository;<% if (dto === 'mapstruct') { %>
+    private <%= entityClass %>Repository <%= entityInstance %>Repository;
+
+    <%_ if (fieldsContainOwnerManyToMany === true) { _%>
+    @Mock
+    private <%= entityClass %>Repository <%= entityInstance %>RepositoryMock;<%_ } _%><% if (dto === 'mapstruct') { %>
 
     @Autowired
     private <%= entityClass %>Mapper <%= entityInstance %>Mapper;<% } if (service !== 'no') { %>
+    <% if (fieldsContainOwnerManyToMany === true) { %>
+    @Mock
+    private <%= entityClass %>Service <%= entityInstance %>ServiceMock;<% } %>
 
     @Autowired
     private <%= entityClass %>Service <%= entityInstance %>Service;<% } if (searchEngine === 'elasticsearch') { %>
@@ -473,6 +482,55 @@ _%>
             <%_ } _%>
             .andExpect(jsonPath("$.[*].<%=fields[idx].fieldName%>").value(hasItem(<% if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { %>Base64Utils.encodeToString(<% } else if (fields[idx].fieldType === 'ZonedDateTime') { %>sameInstant(<% } %><%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase()%><% if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { %><% if (databaseType === 'cassandra') { %>.array()<% } %>)<% } else if (fields[idx].fieldType === 'Integer') { %><% } else if (fields[idx].fieldType === 'Long') { %>.intValue()<% } else if (fields[idx].fieldType === 'Float' || fields[idx].fieldType === 'Double') { %>.doubleValue()<% } else if (fields[idx].fieldType === 'BigDecimal') { %>.intValue()<% } else if (fields[idx].fieldType === 'Boolean') { %>.booleanValue()<% } else if (fields[idx].fieldType === 'ZonedDateTime') { %>)<% } else { %>.toString()<% } %>)))<% } %>;
     }
+    <% if (fieldsContainOwnerManyToMany === true) { %>
+    public void getAll<%= entityClassPlural %>WithEagerRelationshipsIsEnabled() throws Exception {
+        <%_ if (service !== 'no') { _%>
+        <%= entityClass %>Resource <%= entityInstance %>Resource = new <%= entityClass %>Resource(<%= entityInstance %>ServiceMock<% if (jpaMetamodelFiltering) { %>, <%= entityInstance %>QueryService<% } %>);
+        when(<%= entityInstance %>ServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>()));
+        <%_ } else { _%>
+        <%= entityClass %>Resource <%= entityInstance %>Resource = new <%= entityClass %>Resource(<%= entityInstance %>RepositoryMock<% if (dto === 'mapstruct') { %>, <%= entityInstance %>Mapper<% } %><% if (searchEngine === 'elasticsearch') { %>, mock<%= entityClass %>SearchRepository<% } %><% if (jpaMetamodelFiltering) { %>, <%= entityInstance %>QueryService<% } %>);
+        when(<%= entityInstance %>RepositoryMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>()));
+        <%_ } _%>
+
+        MockMvc rest<%= entityClass %>MockMvc = MockMvcBuilders.standaloneSetup(<%= entityInstance %>Resource)
+            .setCustomArgumentResolvers(pageableArgumentResolver)
+            .setControllerAdvice(exceptionTranslator)
+            .setConversionService(createFormattingConversionService())
+            .setMessageConverters(jacksonMessageConverter).build();
+
+        rest<%= entityClass %>MockMvc.perform(get("/api/<%= entityApiUrl %>?eagerload=true"))
+        .andExpect(status().isOk());
+
+        <%_ if (service !== 'no') { _%>
+        verify(<%= entityInstance %>ServiceMock, times(1)).findAllWithEagerRelationships(any());
+        <%_ } else { _%>
+        verify(<%= entityInstance %>RepositoryMock, times(1)).findAllWithEagerRelationships(any());
+        <%_ } _%>
+    }
+
+    public void getAll<%= entityClassPlural %>WithEagerRelationshipsIsNotEnabled() throws Exception {
+        <%_ if (service !== 'no') { _%>
+        <%= entityClass %>Resource <%= entityInstance %>Resource = new <%= entityClass %>Resource(<%= entityInstance %>ServiceMock<% if (jpaMetamodelFiltering) { %>, <%= entityInstance %>QueryService<% } %>);
+            when(<%= entityInstance %>ServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>()));
+        <%_ } else { _%>
+        <%= entityClass %>Resource <%= entityInstance %>Resource = new <%= entityClass %>Resource(<%= entityInstance %>RepositoryMock<% if (dto === 'mapstruct') { %>, <%= entityInstance %>Mapper<% } %><% if (searchEngine === 'elasticsearch') { %>, mock<%= entityClass %>SearchRepository<% } %><% if (jpaMetamodelFiltering) { %>, <%= entityInstance %>QueryService<% } %>);
+            when(<%= entityInstance %>RepositoryMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>()));
+        <%_ } _%>
+            MockMvc rest<%= entityClass %>MockMvc = MockMvcBuilders.standaloneSetup(<%= entityInstance %>Resource)
+            .setCustomArgumentResolvers(pageableArgumentResolver)
+            .setControllerAdvice(exceptionTranslator)
+            .setConversionService(createFormattingConversionService())
+            .setMessageConverters(jacksonMessageConverter).build();
+
+        rest<%= entityClass %>MockMvc.perform(get("/api/<%= entityApiUrl %>?eagerload=true"))
+        .andExpect(status().isOk());
+
+        <%_ if (service !== 'no') { _%>
+            verify(<%= entityInstance %>ServiceMock, times(1)).findAllWithEagerRelationships(any());
+        <%_ } else { _%>
+            verify(<%= entityInstance %>RepositoryMock, times(1)).findAllWithEagerRelationships(any());
+        <%_ } _%>
+    }<% } %>
 
     @Test<% if (databaseType === 'sql') { %>
     @Transactional<% } %>
diff --git a/generators/server/templates/src/test/java/package/web/rest/_AccountResourceIntTest.java b/generators/server/templates/src/test/java/package/web/rest/_AccountResourceIntTest.java
index b8bc29ea74..d4fc0d6727 100644
--- a/generators/server/templates/src/test/java/package/web/rest/_AccountResourceIntTest.java
+++ b/generators/server/templates/src/test/java/package/web/rest/_AccountResourceIntTest.java
@@ -641,7 +641,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
         validUser.setImageUrl("http://placehold.it/50x50");
         <%_ } _%>
         validUser.setLangKey(Constants.DEFAULT_LANGUAGE);
-        validUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
+        validUser.setAuthorities(Collections.singleton(AuthoritiesConstants.ADMIN));
 
         restMvc.perform(
             post("/api/register")
diff --git a/test/app.spec.js b/test/app.spec.js
index 54b3714839..21a007dbb5 100644
--- a/test/app.spec.js
+++ b/test/app.spec.js
@@ -935,7 +935,7 @@ describe('JHipster generator', () => {
                 }));
             });
             it('contains updatePageDirection in language helper', () => {
-                assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/shared/language/language.helper.ts`, /private updatePageDirection/);
+                assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/core/language/language.helper.ts`, /private updatePageDirection/);
             });
         });
     });
diff --git a/test/utils/expected-files.js b/test/utils/expected-files.js
index 6a30ea4602..92ddba4d32 100644
--- a/test/utils/expected-files.js
+++ b/test/utils/expected-files.js
@@ -188,13 +188,13 @@ const expectedFiles = {
         `${CLIENT_MAIN_SRC_DIR}app/admin/user-management/user-management.component.html`,
         `${CLIENT_MAIN_SRC_DIR}app/admin/user-management/user-management.route.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/admin/user-management/user-modal.service.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/user/user.model.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/user/user.service.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/user/user.model.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/user/user.service.ts`,
         `${CLIENT_TEST_SRC_DIR}spec/app/admin/user-management/user-management-delete-dialog.component.spec.ts`,
         `${CLIENT_TEST_SRC_DIR}spec/app/admin/user-management/user-management-detail.component.spec.ts`,
         `${CLIENT_TEST_SRC_DIR}spec/app/admin/user-management/user-management-dialog.component.spec.ts`,
         `${CLIENT_TEST_SRC_DIR}spec/app/admin/user-management/user-management.component.spec.ts`,
-        `${CLIENT_TEST_SRC_DIR}spec/app/shared/user/user.service.spec.ts`,
+        `${CLIENT_TEST_SRC_DIR}spec/app/core/user/user.service.spec.ts`,
     ],
 
     client: [
@@ -302,27 +302,29 @@ const expectedFiles = {
         `${CLIENT_MAIN_SRC_DIR}app/polyfills.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/alert/alert-error.component.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/alert/alert.component.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/auth/account.service.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/auth/csrf.service.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/auth/account.service.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/auth/csrf.service.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/auth/has-any-authority.directive.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/auth/principal.service.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/auth/state-storage.service.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/auth/user-route-access-service.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/auth/principal.service.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/auth/state-storage.service.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/auth/user-route-access-service.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/constants/error.constants.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/constants/pagination.constants.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/index.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/language/find-language-from-key.pipe.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/language/language.constants.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/language/language.helper.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/login/login-modal.service.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/language/language.constants.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/language/language.helper.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/login/login-modal.service.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/login/login.component.html`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/login/login.component.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/login/login.service.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/login/login.service.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/util/request-util.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/shared-common.module.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/shared-libs.module.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/shared.module.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/user/account.model.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/user/account.model.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/core.module.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/index.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/vendor.ts`,
         `${CLIENT_MAIN_SRC_DIR}content/css/documentation.css`,
         `${CLIENT_MAIN_SRC_DIR}content/css/global.css`,
@@ -375,8 +377,8 @@ const expectedFiles = {
         `${SERVER_MAIN_RES_DIR}i18n/messages_fr.properties`,
         `${CLIENT_MAIN_SRC_DIR}i18n/en/global.json`,
         `${CLIENT_MAIN_SRC_DIR}i18n/fr/global.json`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/language/language.constants.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/language/language.helper.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/language/language.constants.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/language/language.helper.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/language/find-language-from-key.pipe.ts`
     ],
 
@@ -385,9 +387,9 @@ const expectedFiles = {
         `${SERVER_MAIN_RES_DIR}i18n/messages_ar_ly.properties`,
         `${CLIENT_MAIN_SRC_DIR}i18n/en/global.json`,
         `${CLIENT_MAIN_SRC_DIR}i18n/ar-ly/global.json`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/language/language.constants.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/language/language.constants.ts`,
         `${CLIENT_MAIN_SRC_DIR}content/css/rtl.css`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/language/language.helper.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/language/language.helper.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/shared/language/find-language-from-key.pipe.ts`
     ],
 
@@ -412,7 +414,7 @@ const expectedFiles = {
         `${CLIENT_MAIN_SRC_DIR}app/account/sessions/sessions.component.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/account/sessions/sessions.route.ts`,
         `${CLIENT_MAIN_SRC_DIR}app/account/sessions/sessions.service.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/auth/auth-session.service.ts`,
+        `${CLIENT_MAIN_SRC_DIR}app/core/auth/auth-session.service.ts`,
         `${CLIENT_TEST_SRC_DIR}spec/app/account/sessions/sessions.component.spec.ts`
     ],
 
@@ -424,7 +426,7 @@ const expectedFiles = {
 
     jwtClient: [
         `${CLIENT_MAIN_SRC_DIR}app/blocks/interceptor/auth.interceptor.ts`,
-        `${CLIENT_MAIN_SRC_DIR}app/shared/auth/auth-jwt.service.ts`
+        `${CLIENT_MAIN_SRC_DIR}app/core/auth/auth-jwt.service.ts`
     ],
 
     oauth2: [