Angular 2 and Spring REST Simple CRUD Application

Angular 2 is one of the Most Popular Front End Web Framework on the internet, Spring MVC is also one of the Most Popular Application Framework on the internet, So today in this article, let’s combine/integrate these two frameworks and build a simple CRUD application.
The goal of the application is to display the list of books, adding a new book, updating the existing book and deleting a book.
We will use Angular 2 in the front end for building forms, displaying the records and making an HTTP calls.
In the backend, using Spring REST we will perform the CRUD operations.


Tools and Technologies Used
  • Spring 4
  • Hibernate 5
  • Angular 2
  • Bootstrap 3
  • MySQL
  • Jackson API 2.8.7
  • Maven 3.3.9
  • Eclipse Oxygen
  • Apache Tomcat 8
  • Visual Studio Code

First let’s create a DB for our application, open your MySQL and add execute the following command,

Let’s start with the backend, Here is the project structure of Spring REST application





I don’t go over in detail about the REST API’s, I believe you all know that the concept of API. Long story short, API’s are nothing but URL’s when we hit those URL’s/Consume those URL’s we will get JSON data that’s it.
So let’s look at how to build such API’s using Spring REST

Since we are using a maven, first let’s add all the dependencies that are required for our application

pom.xml

Next step is to create a Property file inside the resources folder and specify the database properties



db.properties

Once it’s done, let’s configure the spring and hibernate. Inside the config, package create a class called AppConfig and write the following code.

We will annotate this class with @Configuration, @PropertySource, @EnableTransactionManagement and @ComponentScan

@Configuration: It is a replacement to the XML based configuration for configuring spring beans. So instead of an XML file, we write a class and annotate that with @Configuration and define the beans in it using @Bean annotation on the methods.

@PropertySource: Specify the classpath of the property file. Reading values from a property file are far superior to hard coding them in our class files. If we hard code then we need to recompile if we want to change any of them.

@EnableTransactionManagement: It enables the transaction management. @ComponentScans: To scan the multiple packages.

AppConfig.java

Next step is to create MyWebAppInitializer class to initialize the servlet container, instead of using traditional web.xml, we will use java class that will extends AbstractAnnotationConfigDispatcherServletInitializer.



MyWebAppInitializer.java

Next step is to create WebConfig class inside the config package, we will annotate this class with @Configuration, @EnableWebMvc, and @ComponentScan

@EnableWebMvc: @EnableWebMvc is used to enable Spring MVC. @EnableWebMvc is equivalent to <mvc:annotation-driven /> in XML.

WebConfig.java

Above three files are required for the spring and hibernate configuration.

Now, let’s write the model class, create a Book class inside the model package.




Book.java

Now, let’s create an Interface for DAO, we will create BookDAO interface inside the dao package

BookDao.java

Now, let’s implement those methods in the BookDaoImp class and annotate this class with @Repository

@Repository: It is an annotation that marks the specific class as a Data Access Object, thus clarifying its role.

BookDaoImp.java

Now, let’s create another Interface for service, we will be creating this service inside the service package



BookService.java

Now, let’s implement those methods in the BookServiceImp class and annotate this with @Service

@Service: This tells hibernate it is a Service class where you will have @Transactional etc Service layer related annotations so hibernate treats it as a Service component.

BookServiceImp.java

Finally, we will create a controller BookController inside the controller package and annotate with @RestController, which specifies that this is a REST controller



BookController.java

That’s it for the backend, now we have 5 REST API’s

HTTP Method CRUD Operation Description
POST Create Create a new resource ( equivalent to SQL INSERT statement)
http://localhost:8037/spring-mvc-restfull-crud-example/book
GET Read Retrieve a resource ( equivalent to SQL SELECT statement)
http://localhost:8037/spring-mvc-restfull-crud-example/book
http://localhost:8037/spring-mvc-restfull-crud-example/book/{ID}
PUT Update Update or modify a resource ( equivalent to SQL UPDATE statement)
http://localhost:8037/spring-mvc-restfull-crud-example/book/{ID}
DELETE Delete Delete a resource ( equivalent to SQL DELETE statement)
http://localhost:8037/spring-mvc-restfull-crud-example/book/{ID}

We will consume these API’s in front end using Angular 2.



Let’s look at the front end application,
Before creating an Angular application make sure to install Node.js and npm on your machine,

First, let’s install angular CLI globally on our machine,

Create a new project,

What is the purpose of the app.module.ts?
Is it to start up your application, and set the links to your other modules.
1 – Modules are the logic layers of your application. Each module is there to package things logically so that it’s easier for people to understand and maintain your application, made of several modules. For example, if you are doing a rich application, you should have a LoginModule, an AuthenticationModule, etc…
2 – You need to import things in your module so that Angular knows what it is going to use. Basically, your LoginModule will need the Angular FormModule, which might not be needed for the AuthenticationModule
3 – This leads us here: The AppModule, therefore, should only import the others modules it is linked to, and provide the services that will be needed globally. Your future LoginModule won’t need a service to be provided, but the AuthenticationModule, which will have an AuthenticationServicewill most probably do.

What is Angular Router?



Angular Router is an official Angular routing library, written and maintained by the Angular Core Team.
It’s a JavaScript router implementation that’s designed to work with Angular and is packaged as. @angular/router
First of all, Angular Router takes care of the duties of a JavaScript router:

  • it activates all required Angular components to compose a page when a user navigates to a certain URL
  • it lets users navigate from one page to another without page reload
  • it updates the browser’s history so the user can use the back and forward buttons when navigating back and forth between pages.

In addition, Angular Router allows us to:

  • redirect a URL to another URL
  • resolve data before a page is displayed
  • run scripts when a page is activated or deactivated
  • lazy load parts of our application.

Let’s start with,

app.module.ts

Keep in mind: At least one module and component are required to initiate Angular2 App.





Do I need app.component.ts?
Not necessary
. That is just a name of .ts file. It can be any other component. But as said at least one module and component are required to initiate Angular2 App.

app.component.ts

app.component.html

Now, create two folders inside the app folder, book and others

Inside the book folder, created these files,

Inside the others folder, create these files,



pageNotFound.component.ts

Basically, there are three types of directives in angular2 according to documentation.

  • Component
  • Structural directives
  • Attribute directives

Component

is also a type of directive with template, styles and logic part which is the most famous type of directive among all in angular2.

  1. To register a component we use @Component meta-data annotation.
  2. A component is a directive which uses shadow DOM to create encapsulated visual behavior called components. Components are typically used to create UI widgets.
  3. A component is used to break up the application into smaller components.
  4. Only one component can be present per DOM element.
  5. @View decorator or templateurl template is mandatory in the component.



home.component.ts

bookList.component.ts

bookList.component.html

bookList.component.css

book.ts

book.service.ts



book.component.ts

book.component.html



book.component.css

So now first let’s run the Spring REST application, and then run the Angular application. To run the angular application, navigate to the project directory, and execute the following command,

At this point, if you navigate to http://localhost:4200 (default URL), you will see this web page. If you see this webpage then congratulations you made it, if not then double check the code.

Love this post?

Help me to buy a cup of coffee/Support us by donating.
All the donations will be go to the website maintenance/improvement.








That’s it for this article, I hope this article helped you in one or the other way, do let me know how this article helped you, I will see you in the next article.

Download the Front-end partDownload

Download the Backend partDownload

Download the Complete projectDownload

About the author

Bushan Sirgur

Well, I am Bushan Sirgur from Banglore, India. Currently, I am working as a Software Developer in a Service Base Company. I am interested in JAVA/J2EE, Angular 2, JavaScript, jQuery, MongoDB.

View all posts

30 Comments

    • Hello LFCM, I have explained both front and backend. In the first part I have explained about backend using Spring REST and hibernate, that will communicate with the database.

        • Oh sorry about that. I forgot to create a DB. I will add that code. We will create the only database. All the tables will be created automatically, that is why we have written hibernate.hbm2ddl.auto=update in the db.properties file. This will create the tables for us and that’s the beauty of hibernate. All we need to do is create a DB that’s it.

          • All good. I’d also make the suggestion that you give it a try with MySQL 8. It’s a pain and I’m having issues getting the app up and running with it. I think it would be awesome to build this out with HSQL or Postgress. MySQL is so bloated and messed up these days.

  • Here is my stack trace if you are interested….

    14-Jul-2018 00:00:26.382 WARNING [C3P0PooledConnectionPoolManager[identityToken->1hge16c9w1626fc7188ouyk|455a4819]-HelperThread-#2] com.mchange.v2.resourcepool.BasicResourcePool. com[email protected]3e119995 — Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
    java.sql.SQLException: Unknown system variable ‘query_cache_size’
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:545)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115)
    at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1983)
    at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1936)
    at com.mysql.cj.jdbc.StatementImpl.executeQuery(StatementImpl.java:1422)
    at com.mysql.cj.jdbc.ConnectionImpl.loadServerVariables(ConnectionImpl.java:2831)
    at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:2381)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1739)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1596)
    at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:633)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:347)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:219)
    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
    at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
    at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)

  • Hello LFCM,

    Even I don’t use much but I have created that web service with MySQL long back so it is there but in my future videos I will use HSQL or PostgreSQL.
    I am planning make video series on Angular and Spring REST, if you want to know more about it, do subscribe to our YouTube channel @ https://www.youtube.com/b2tech
    Thanks for reaching us.

  • Access to XMLHttpRequest at ‘http://localhost:8080/spring-mvc-restfull-crud-example/book’ from origin ‘http://localhost:4200’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

  • I intended to send you a very small observation to say thanks the moment again on the awesome thoughts you’ve featured in this article. It has been so shockingly generous with you to provide publicly what many individuals would’ve sold for an electronic book to end up making some bucks for themselves, particularly considering the fact that you could have tried it if you ever desired. The thoughts likewise served to become a fantastic way to know that other people have the identical zeal the same as mine to see a good deal more when considering this condition. I’m certain there are millions of more pleasant times in the future for individuals that read through your website.

  • Hello Bushan, i am the same guy i asked for a query on youtube two days back. It is…

    Hi i did as per the instructions. But in console rather than a json object i am getting this,
    zone.js:3243 XHR finished loading: GET “http://localhost:8080/bookapi/api/book”.
    Can you advise me and tell me where i went wrong? The REST API is working. I checked it with postman, i am getting a ping(response).

  • Hello Bushan, i am getting this issue..
    Hi i did as per the instructions. But in console rather than a json object i am getting this,
    zone.js:3243 XHR finished loading: GET “http://localhost:8080/bookapi/api/book”.
    Can you advise me and tell me where i went wrong?
    REST API is working, so back-end is working. In front end the page is being loaded but the data is not being transmitted to front-end.

      • Bushan Hi. Today i checked again but instead of chrome i used an older Mozilla Firefox with firebug in it. In this the JSON object is being shown. But when i am using chrome i am not getting it. Is there a reason why this is happening. Is there some kind of setting i need to do, to get in chrome’s console?

  • Hi Bhushan,

    Thanks for your video and such a good explanation.
    I am getting the error below while running tomcat server first time. Please help to guide me to fix the same.

    May 13, 2019 1:57:38 PM org.apache.catalina.core.AprLifecycleListener init
    WARNING: The APR based Apache Tomcat Native library failed to load. The error reported was [D:\Tomcat 9.0\bin\tcnative-1.dll: Can’t load AMD 64-bit .dll on a IA 32-bit platform]
    java.lang.UnsatisfiedLinkError: D:\Tomcat 9.0\bin\tcnative-1.dll: Can’t load AMD 64-bit .dll on a IA 32-bit platform
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at org.apache.tomcat.jni.Library.(Library.java:42)
    at org.apache.tomcat.jni.Library.initialize(Library.java:206)
    at org.apache.catalina.core.AprLifecycleListener.init(AprLifecycleListener.java:198)
    at org.apache.catalina.core.AprLifecycleListener.isAprAvailable(AprLifecycleListener.java:107)
    at org.apache.catalina.connector.Connector.(Connector.java:80)
    at org.apache.catalina.startup.ConnectorCreateRule.begin(ConnectorCreateRule.java:64)
    at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1173)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1431)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:567)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:608)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:306)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:491)

  • I am getting the following error

    Jun 23, 2019 6:56:46 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:bookapi’ did not find a matching property.
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Server version: Apache Tomcat/8.0.36
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Server built: Jun 9 2016 13:55:50 UTC
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Server number: 8.0.36.0
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: OS Name: Windows 10
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: OS Version: 10.0
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Architecture: amd64
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Java Home: C:\Program Files\Java\jdk-11.0.2
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: JVM Version: 11.0.2+9-LTS
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: JVM Vendor: Oracle Corporation
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: CATALINA_BASE: C:\Users\saivi\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: CATALINA_HOME: C:\apache-tomcat-8.0.36
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Dcatalina.base=C:\Users\saivi\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Dcatalina.home=C:\apache-tomcat-8.0.36
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Dwtp.deploy=C:\Users\saivi\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Dfile.encoding=Cp1252
    Jun 23, 2019 6:56:46 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk-11.0.2\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_201/bin/server;C:/Program Files/Java/jre1.8.0_201/bin;C:/Program Files/Java/jre1.8.0_201/lib/amd64;C:\oraclexe\app\oracle\product\11.2.0\server\bin;;C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\PuTTY\;C:\Program Files\Java\jdk-11.0.2\bin;C:\Program Files\Apache Software Foundation\apache-maven\bin;C:\Program Files\Git\cmd;C:\Users\saivi\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Java\jre1.8.0_201\bin;C:\Users\saivi\AppData\Local\Programs\Python\Python37-32;C:\Users\saivi\AppData\Local\Programs\Microsoft VS Code\bin;C:\apache-maven-3.6.1\bin;C:\Users\saivi\Desktop;;.
    Jun 23, 2019 6:56:46 PM org.apache.catalina.core.JreMemoryLeakPreventionListener lifecycleEvent
    SEVERE: Failed to trigger creation of the GC Daemon thread during Tomcat start to prevent possible memory leaks. This is expected on non-Sun JVMs.
    java.lang.ClassNotFoundException: sun.misc.GC
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:315)
    at org.apache.catalina.core.JreMemoryLeakPreventionListener.lifecycleEvent(JreMemoryLeakPreventionListener.java:286)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:394)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:99)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:580)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:603)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:310)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:484)

    Jun 23, 2019 6:56:46 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler [“http-nio-8080”]
    Jun 23, 2019 6:56:46 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
    INFO: Using a shared selector for servlet write/read
    Jun 23, 2019 6:56:46 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler [“ajp-nio-8009”]
    Jun 23, 2019 6:56:46 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
    INFO: Using a shared selector for servlet write/read
    Jun 23, 2019 6:56:46 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 869 ms
    Jun 23, 2019 6:56:46 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Catalina
    Jun 23, 2019 6:56:46 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/8.0.36
    Jun 23, 2019 6:56:46 PM org.apache.catalina.loader.WebappLoader buildClassPath
    INFO: Unknown loader [email protected] class jdk.internal.loader.ClassLoaders$AppClassLoader
    Jun 23, 2019 6:56:46 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
    INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [174] milliseconds.
    Jun 23, 2019 6:56:47 PM org.apache.catalina.loader.WebappLoader buildClassPath
    INFO: Unknown loader [email protected] class jdk.internal.loader.ClassLoaders$AppClassLoader
    Jun 23, 2019 6:56:48 PM org.apache.jasper.servlet.TldScanner scanJars
    INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
    Jun 23, 2019 6:56:48 PM org.apache.catalina.core.ApplicationContext log
    INFO: No Spring WebApplicationInitializer types detected on classpath
    Jun 23, 2019 6:56:48 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler [“http-nio-8080”]
    Jun 23, 2019 6:56:48 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler [“ajp-nio-8009”]
    Jun 23, 2019 6:56:48 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 2073 ms

  • Access to XMLHttpRequest at ‘http://localhost:8080/spring-mvc-restfull-crud-example/book’ from origin ‘http://localhost:4200’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
    I add @CrossOrigin at the class level but not resolved the problem.

  • hi , im following your steps but getting this error:

    Bean instantiation via factory method failed

    Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘getSessionFactory’ defined in com.yinka.spring.config.AppConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.hibernate5.LocalSessionFactoryBean]: Factory method ‘getSessionFactory’ threw exception; nested exception is java.lang.NullPointerException

Leave a Reply

Your email address will not be published. Required fields are marked *