Friday, 22 January 2021

Disable SpringBoot Data-Source Auto-Config

 package com.ynz.finance.pricetrend;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;

@SpringBootApplication(exclude = {
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
HibernateJpaAutoConfiguration.class
})
public class FindAllNasdaq233DayAveragePrices {

public static void main(String[] args) {
SpringApplication.run(FindAllNasdaq233DayAveragePrices.class, args);
}

}

Caused by: java.awt.HeadlessException

The error happens as Integrating SpringBoot application with JavaFX application; 

what does headless mean? 

Headless software (e.g. "headless Java" or "headless Linux",) is software capable of working on a device without a graphical user interface. ... 


solution: 

SpringApplicationBuilder builder = new SpringApplicationBuilder(DemoApplication.class);
builder.headless(false);
applicationContext = builder.run();

SpringApplicationBuilder vs SpringApplication

Both are used to bootstrap a Spring boot application context. What difference between them? 

SpringApplication

SpringApplication is a class to bootstrap a Spring application from a Java main method. It creates an appropriate ApplicationContext instance (depending on the classpath), registers a CommandLinePropertySource to expose command line arguments as Spring properties, refreshes the application context, loading all singleton beans, and triggers any CommandLineRunner beans.


SpringApplicationBuilder

SpringApplicationBuilder is a builder for SpringApplication and ApplicationContext instances with convenient fluent API and context hierarchy support.


SpringApplication do more than SpringApplicationBuilder


Regular expressions


A regular expression (regex) is a language, for it has a syntax.  It is used to describe a pattern among characters, therefore it may simplify the process to parse a string or a text. You may parse once rather than repeating the process many times.

Character Classes 
The term refers to a set of characters that you can enclose within square brackets, for instance [sz]; it used to specify one of the set may be matched, or say it is a pattern that needs to be checked.

Class type: 
Simple [agfd]  match exactly one from a, g, f or d
Range [a-f0-7] match one from the range a to f (both included) or 0-7(both included)
Negation [^123k-m] matches exactly one character that is not 1 2 or from the range k to m (both included)

Predefined Character Classes
Java's regex engine supports predefined character classes for your convenience.

\d : a digit [0-9]
\D : a non-digit[^0-9]
\s : a white space [\t (tab), \n (new line), space, \x0B(end of line), \f(form feed), \r(carriage)]
\S: a non-white space [^\s]
\w: a word character: [a-zA-Z0-9]
\W: a nonword character: [^\w]
\t: tab
\n: a new line
. : wildcard matching any character.

Boundary Matcher
^: matching the beginning of a line. fx: ^dog$. it means a line contains a single word 'dog'
$: matching the end of a line.
\b: a word boundary  fx: \bdog\b    dog  an exact word dog is matched
\B: a non-word boundary  fx: \bdog\B   within doggie dog is matched

Quantifier
X? : matching X  0 or 1 time
X+: matching X 1 or many times
X*: matching X 0 or many times
X{3}: matching exactly 3 times
X{1,3}: matching X 1 to 3 times

Logic
X|Y: logic OR; matching X or Y
XY: X pattern followed by the Pattern Y
(X): capturing as a group. 



Friday, 15 January 2021

Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!

 How to prevent the warning message? 

This or a similar warning is emitted by a plugin that processes plain text files but has not been configured to use a specific file encoding. So eliminating the warning is simply a matter of finding out which plugin emits it and how to configure the file encoding for it. This is as easy as adding the following property to your POM (or one of its parent POMs):


  1. <project>
  2. ...
  3. <properties>
  4. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  5. </properties>
  6. ...
  7. </project>


Monday, 11 January 2021

Understanding Spring and Config It

Spring Framework

Spring is built on the top of JEE. It re-manage the usage of JEE API and releasing developers from some trivial works.

Init a minimal spring project that needs the following major dependencies: 
spring-context: defines the actual Spring Injection Container and has a small number of dependencies: spring-core, spring-expression, spring-Aop, and spring-beans.
spring-core: is the core framework that provides the container required to implement Dependency Injection and inversion of control.

Application context:

ApplicationContext is a sub-interface of BeanFactory; so it is also a BeanFactory. In addition, it needs to know some concepts, Inversion of Control(IOC) and IOC container, Dependency Injection(DI),  and bean metadata.  The concept of IOC is about who is going to drive the car; driving yourself, or hiring a driver driving for you. That is the inversion of control. In another word in the software, who is going to inject the dependencies; injecting yourself, or leaving a container injecting for you. We leave the controls of creating an instance and its dependencies to a container, so as to dissolve client code from coupling with the underlying dependencies. 

The application context acts as the heart of the Spring framework. It encapsulates the bean factory,  and loading bean metadata externally for bean creation;  it provides a mechanism for the creation of beans in the correct order, meanwhile providing all beans dependency injections;  beans are created as the application startup, and managed in an IOC container ready for providing bean reference when the code request for it.

Developers mainly config IOC container and leaving bean creations to the container. By this way, it decouples class dependencies and leaving all of these couplings within the container. We use a kind of metadata or whatever it is called to tell the IOC container which beans are needed and their dependencies, just like a blueprint that depicts how an instance is created.  For the client-side code, it uses the @Autowire to request IOC container at the point it needs an instance reference. It means that the IOC container needs to provide the instance reference and assemble its all dependencies, i.e. it is also called Dependency Injection(DI)


DI and IOC container:  

Injection means that at a point that the code needs to refer to an instance, it requests the container and achieves its reference. All DI is handled by the bean factory, which is in charge of figuring bean dependencies, and in charge of assembling all these beans together and return the root reference to the client.  

IOC container manages dependent classes and their instances in a graph. It wires all class dependencies once and re-uses it as any point.  It, therefore, reducing a lot of repeated work and removes the coupling of classes from the client code.

DI and IOC are carried by two Spring packages, i.e. Spring core and Spring context. At a minimum, if you include these two packages in your project, then you may implement DI.

Configuring Application Context

Configuring Spring differently for different deployments, which may include different beans, different properties, different databases etc.

We looked at multiple ways of activating profiles. Let's now see which one has priority over the other and what happens if you use more than one, from highest to lowest priority:

  1. Context parameter in web.xml
  2. WebApplicationInitializer
  3. JVM system parameter
  4. Environment variable
  5. Maven profile 

Profiles:

@Profile is applied with @Configuration or individual bean method level.

@Profile("!dev")
@Bean

Spring Core Property together,  i.e. spring.profiles.active = 'dev', indicates that the 'dev' profile is activated. It realises that the configurations, beans, or properties can be switched according to the activated profile.

It is able to activate a @Profile externally during application start-up.

JVM system parameter:
-Dspring.profiles.active=dev

Program argument:
spring.profiles.active=dev

Environment variable:
in UNIX: export spring_profile_active=dev
or in IDE edit Configurations: set Environment variable; spring.profiles.active=dev

Application property file:
spring.profiles.active=dev

Command line parameter:
java -jar any.jar --spring.profiles.active=dev

Spring profile can be activated via Maven profiles, by specifying spring.profiles.active configuration property.

ref. to https://www.baeldung.com/spring-profiles

Using @ActiveProfile in Tests, making it easy to specify what profiles active.

Value injection: 
@Value is used for injecting property into the code. It is used in the fields or method arguments.
It may inject a value object from a property file or system or environment variables.

Spring expression language(SpEL) 

SpEL is an expression language that supports querying and manipulating an object graph at runtime. It is a single well supported within the Spring community, but it is self-contained and can be used independently. SpEL supports calling methods, accessing properties, and calling constructors.

We often use SpEL for Annotation Configuration; like putting a default value on fields, methods, and method or constructor parameters. 
@Value("#{new Boolean(environment['spring.profiles.active']!='dev')}")
private boolean is24Hours;
Spel can do a logic operation, may be helpful.

https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#expressions

Proxies

Proxy is a pattern, it is used to add behaviours to classes. Spring uses a lot of proxies to add aspected behaviours, for instance, transaction boundaries, security check,  logging, cache etc.  

Spring uses both JDK and CGLib-based proxies in its operations. JDK uses an interface to generate a proxy class in order to wrap the target class, but CGLib extends directly from the target class and overriding the point-cut. 

Bean Scopes

Bean scopes are critical concepts for understanding Spring in depth.

  • Singleton:  By default, all classes decorated by @Component are instantiated as a singleton, namely one instance per spring application context.  It needs to watch out states shared across the user of the bean.
  • Prototype;  Bean definition stored in IOC;  new instance every time it is referred. The definition is stored in IOC.
  • Session: It applies to web environment only. Session scope means one instance of a bean per user session.  Definition of the bean is stored in an IOC container when a session is created, the bean is created.
  • Request:  It applies to web environment only. Within a user session, the user may trigger several HTTP requests. A request scoped bean has a life cycle as the request where it is spawned.

Component Scanning

There are three ways to provide bean factory blueprints, i.e. an XML fileJava-based config, or Component scanning. Today, component scanning is the favourite for defining bean metadata. 

Component scanning(@ComponentScan) scans a base package(com.xxx.xxx) and load classes decorated by @Component or its derivatives(@Service, @Repository, etc) into the bean factory.  @ComponentScan without arguments tells Spring to scan the current package and all of its sub-packages.

Using @ComponentScan annotation along with @Configuration annotation together may bring Java-based blueprints and Component scanning metadata together to BeanFactory via an ApplicationContext.

In SpringBoot, using @SpringBootApplicatoin includes the component scanning by default. @ComponentScan(basePackages="xxx.zzz.yyy") defines the entry to scan for components.  Properties file can be scanned and loaded @PropertySource("classpath: application. properties"), it externally defines a location of customer property files

In a component scanning process, it builds up the dependency graph automatically according to component dependencies,  also called Dependency Injection(DI). From the client-side of beans, it is referred to as an auto-wiring process using @Autowired annotation at the point that the code needs the reference of the instance. IOC container and DI build up bean graph for clients and can be reused many times afterwards. This is a big saving. 

Using @Qualifier or @Primary to solve type ambiguity, because of one type having more than one implementation.

Component scanning is also used with conditional configuration.

Lifecycle methods: 

Leveraging JSR-250, not Spring specific. 

Post Construction (@PostConstruct) means to do something before a bean become use phase. It must be a void method without arguments. It is called after property setting is completed. it is used to init.

Pre Destroy(@PreDestroy) means to do something before the application context closes. The method is called before the application context is about to remove the bean. The method may be used to close the opened resources.

Both of them not included after java 9. 


Bean Life Cycles

There are three phases, initialization, use(interacting with Spring IOC container), and deconstruction. The most time of life cycle is spent during the use phase; the most complicated phase is the initialization, and deconstruction is the end of the life cycle. The following diagram illustrates the initialization. It begins with the creation of the application context and follows up with the bean factory initialization phase and bean initialization and instantiation. It is a phase we can impact the behaviour of application most. 

Init phase:  creating of App context => bean factory initialization phase=>bean initialization and instantiation

Load bean definitions: 

Bean definition loaded: 

The first step loading bean definition into the bean factory from all sources:
  1. Java configuration(@Configuration,@Bean,@Value, @DependsOn,@Import)
  2. XML configuration; not often used now. 
  3. Component scanning and auto-configuration. (@ComponentScan,@Component)
You can do all of them, but the best is to pick up one and stick with it.  The bean definition (class metadata); at the point, has been loaded, and instance references are created, however, instances have not been created. It is import to know that at this phase there is no bean having been instantiated.  At this phase, the bean factory contains bean metadata. and bean references.

Post-process bean definitions:

BeanFactory Post-Processors: Before bean instantiation, and after bean definition loading. This phase allows modifying any bean in the factory prior to instantiation. One of the most familiar examples of this is the  PropertySourcesPlaceholderConfigurer

Bean postprocess is the first extension point, allowing to impact bean factory. You can extend from the BeanFactoryPostProcessor to write a custom code to do something to beans or a subset of beans. 
It is not common to write your won, but it is good to understand you can use this to your advantage. It is very common to use existing ones(registering scope, properties)

Bean factory post-processors(BFPP) and bean definitions must be static; removing risks of side effects of dynamic instances.

At the end of this stage, the bean factory is loaded with references; the bean factory and all beans are configured; all system-level work is completed in Spring; It is ready for the next stage. 

Instantiation phase: 

for each bean Bean factory need to do: 

Construction

Beans are instantiated using constructors; Done in the correct order to ensure dependencies are created first; Creating only singletons at this  point, anything other than a singleton bean will not be constructed because they are prototype or session beans;

Eager vs. Lazy
By default, all beans are instantiated eagerly. To truly be lazy, there can be nothing that depends on them. Even you label a bean as a lazy bean, the application context reserve the right to ignore.

At the end of this phase, bean reference is still kept inside the Bean Factory; instances have been constructed, but not ready for use yet.

Setters:

post-initialization DI should only be done on optional beans or dynamic beans.
Autowiring occurs(non-constructor based)

This is another chance to auto-wire after beans having been instantiated.  Autowiring occurs on setters with @Autowired  annotation. 

At the end of this phase, all dependencies are injected, beans are fully initialized, but still not ready for use.

Bean post-processor(pre-initializer)

This is the final point of configuration manipulation. each bean may have additional behaviours added at this point; the bean post-processing event. there are two types of extensible and generic processing: before and after initializer.

Initializer: 
This is the second BeanPostProcessor action. @PostConstruct methods called here.

many other things happen during this initializer phase. 

BeanPostProcessor Interface
The bean post-processor interface is used for pre or post initializer steps. The BeanPostProcessor interface allows you to inject common behaviour to a "class" of beans. It still operates on specific beans.  The framework leverages lots of these, a lot of proxies are built during this pre-phase especially.  



Bean post-processor(Post-init)
at the end of this phase, beans have been instantiated and initialized.
Dependencies have been injected.
Beans are finally ready for use.

Use phase:

Most time is spent in this phase; ApplicationContext serves proxies to the original class; ApplicationContext maintains handle to each bean(singleton)

context-aware beans
Spring provides interface ApplicationContextAware; gives your class a handle to the ApplicationContext; not a very common interface to use, but is available during the use phase.
Actually, the context-aware beans get an application context reference injected.

https://dzone.com/articles/spring-bean-lifecycle-using-spring-aware-interface


Destruction phase:

When close is called on the ApplicationContext, the destruction phase of the life cycle begins, and it is a one-way door. Any @PreDestroy method is called at this point, in which beans are not destroyed, but only destroyed by GC.


Aspect-Oriented Programming

An Aspect stands for a cutting concern across many classes, and it is important to know AOP change your code behaviour in the runtime, only in the runtime. 

AOP is for reusing code on a cutting-cross concern, fx: logging, transaction management, caching, security, checking method performance, handling common exceptions etc. AOP programming is an easy way of applying the same code in many classes, to extend or modify its existing method's behaviour. 

In Spring, AOP is implemented by a JDK dynamic proxy(AspectJ) or a CGLIB proxy(inheritance).  AOP is implemented as a proxy pattern or OOP inheritance. 

Dependencies: 
spring-core, spring-context, and aspectjweaver 

Concept and Terms:

In the Spring, basically, AOP concept/terms/annotations have one to one mapping relationship; exactly understanding terms help to implement AOP in the code.  
  • Primary concern: business logic
  • Secondary concern: a supportive function. 
  • Weaving: linking Aspect with other application types or objects to create an advised object. 
  • Target object: object being advised by one or more aspect; referred to as the advised object. 
  • Joinpoint: a spot in your BL code, where a cutting concern code can be applied there.
  • Pointcut: selecting a joint point to apply a common-concern code that matches join points. 
  • Aspect: a concern that cuts across multiple class. 
  • Advice: an implementation of Aspect. the code to solve the cutting concerns
  • AOP proxy: a proxied target created by the AOP framework, to carry out the Advice.
The major points as Implementing an AOP: 
You need to define JoinPoint and then using PointCut to select the JoinPoint, Afterwards implementing the cutting concern code in an Advice. 


Pointcut syntax:

designator("r p.c.m(arg)") 
r:return type; 
p:package; 
c: class; 
m: method; 
arg:args

Supported Pointcut Designators

Spring AOP supports the following AspectJ pointcut designators (PCD) for use in pointcut expressions:

execution: For matching method execution join points. This is the primary pointcut designator to use when working with Spring AOP.

within: Limits matching to join points within certain types (the execution of a method declared within a matching type when using Spring AOP).

this: Limits matching to join points (the execution of methods when using Spring AOP) where the bean reference (Spring AOP proxy) is an instance of the given type.

target: Limits matching to join points (the execution of methods when using Spring AOP) where the target object (application object being proxied) is an instance of the given type.

args: Limits matching to join points (the execution of methods when using Spring AOP) where the arguments are instances of the given types.

@target: Limits matching to join points (the execution of methods when using Spring AOP) where the class of the executing object has an annotation of the given type.

@args: Limits matching to join points (the execution of methods when using Spring AOP) where the runtime type of the actual arguments passed have annotations of the given types.

@within: Limits matching to join points within types that have the given annotation (the execution of methods declared in types with the given annotation when using Spring AOP).

@annotation: Limits matching to join points where the subject of the join point (the method being run in Spring AOP) has the given annotation.



You need to enable AOP @EnableAspectJAutoProxy
Enables support for handling components marked with AspectJ's @Aspect annotation, similar to the functionality found in Spring's <aop:aspectj-autoproxy> XML element. To be used on @Configuration classes 

Using @Aspect to define an Aspect, but must together with a @Component, so that @Component can detect it. 

Type of Advice:

  • Before advice:  advice executed before a joint point.
  • After returning advice: Advice to be executed after a join point completes normally.
  • After throwing advice: Advice to be executed if a method exits by throwing an exception.
  • After(finally)  advice: Advice to be executed regardless of means by which a join point exits(normal or exceptional return).
  • Around advice:  performing custom behaviour before and after the joinpoint.

Friday, 8 January 2021

Java Chart Frameworks

JFree chart is the most recommended one.  


The major elements are involved as using JFree framework. 

ChartPanel: it is specific to the JFree; it is a container to hold the JFree charts, and it adapts to the SWING frame.   

XYPlot: it is the basic plotter, that draws an x-y diagram on the canvas. 

Axis: Date axis(X-axis) or Number axis(Y-axis) stands for Price or volume. 

Dataset: Candle dataset; or XY data set.


JFree candlestick chart, combined subplots. 

https://examples.javacodegeeks.com/desktop-java/jfreechart/jfree-candlestick-chart-example/


Creating a candlestick chart and line chart on a common chart

XYPlot plot = (XYPlot)chart.getPlot();
        XYDataset dataset2 = getDataset2(); //This is where you get your line data
        plot.setRenderer(1, new XYLineAndShapeRenderer(true, false));
        plot.setDataset(1, dataset2);


It is supposed to work with Java FX, via a Jfree-fx package. However,  I didn't make it work. The chart-viewer has a version error. 

Java FX candlestick chart

https://github.com/rterp/StockChartsFX


ChartFx is a scientific charting library developed at GSI for FAIR with focus on performance optimised real-time data visualisation at 25 Hz update rates for data sets with a few 10 thousand up to 5 million data points common in digital signal processing applications. Based on earlier Swing-based designs used at GSI and CERN, it is a re-write of JavaFX's default Chart implementation and aims to preserve the feature-rich and extensible functionality of earlier and other similar Swing-based libraries while addressing the performance bottlenecks and API issues. The motivation for the re-design has been presented at IPAC'19 (paperposter).


https://github.com/GSI-CS-CO/chart-fx


Java FX structure 

Application: have Stage(s); a Stage has a Scene; a Scene has a root Node, Node has children Nodes. 

TreeViewTable: combine tree view and table view together.

SplitPane: 

CombinedSubPlots

ChartViewer: Jfree-fx allows JFree Chart display on the Java FX 



How to integrate Java FX with SpringBoot


https://github.com/mvpjava/springboot-javafx-tutorial


Tutorial: Reactive Spring Boot Part 3 – A JavaFX Spring Boot Application

 








Turning off A package logging

 If you use Spring Boot, you may set to in the application.properties file. Example:

logging.level.org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer=OFF

Wednesday, 6 January 2021

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext':

Solution: 

rolling <groupId>com.h2database</groupId> back to lower version, <version>1.4.199</version>


 Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2021-01-06 00:59:34.021 ERROR 17888 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nasdaqStocksRepository' defined in com.ynz.finance.pricetrend.domain.repository.NasdaqStocksRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:342) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1697) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1442) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:624) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:612) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.data.repository.config.DeferredRepositoryInitializationListener.onApplicationEvent(DeferredRepositoryInitializationListener.java:51) ~[spring-data-commons-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.data.repository.config.DeferredRepositoryInitializationListener.onApplicationEvent(DeferredRepositoryInitializationListener.java:36) ~[spring-data-commons-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]

at com.ynz.finance.pricetrend.DemoApplication.main(DemoApplication.java:25) [classes/:na]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]

at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]

at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.3.4.RELEASE.jar:2.3.4.RELEASE]

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1794) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]

... 33 common frames omitted

Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:275) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:176) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:118) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1224) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1255) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:391) ~[spring-orm-5.2.9.RELEASE.jar:5.2.9.RELEASE]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_201]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_201]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_201]

at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_201]

Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

... 17 common frames omitted



Process finished with exit code 0





Can Jackson Deserialize Java Time ZonedDateTime

Yes, but must include JSR310. Thus ZonedDateTime can be deserialized directly from JSON response to POJO field. <dependency> <g...