Springboot multiple Oracle driver versions - oracle

For a Springboot project I need to connect to two different instances of existing Oracle databases. The major versions of these databases are too dissimilar that I will need to use two different drivers (I obviously tried anyway).
The specific drivers are and are loaded using maven dependencies:
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.10.0.0</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.5.0</version>
</dependency>
Both drivers are on the classpath and the classnames are identical.
How can I solve this?

Related

difference between javax.persistence.Entity vs jakarta.persistence.Entity [duplicate]

I've recently started to learn spring boot, data jpa. As I can see from this, the spring boot data jpa starter uses jakarta.persistence-api instead of javax.persistence-api:
<artifactId>spring-boot-starter-data-jpa</artifactId>
...
<dependencies>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<exclusions>
<exclusion>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
</exclusion>
...
</exclusions>
</dependency>
</dependencies>
What is the differences between jakarta.persistence-api and javax.persistence-api? What is the reason of this replacement?
From Java Persistence API on Wikipedia:
The Java Persistence API (JPA), in 2019 renamed to Jakarta Persistence, is a Java application programming interface specification that describes the management of relational data in applications using Java Platform, Standard Edition and Java Platform, Enterprise Edition/Jakarta EE.
After Java EE was open sourced by Oracle and gave the rights to the Eclipse Foundation they were legally required to change the name from Java as Oracle has the rights over the Java brand. The name Jakarta was chosen by the community. You can find more information by reading Transition from Java EE to Jakarta EE and Jakarta EE - No Turning Back.

Difference between graphql-java-kickstart vs Spring graphql

There are two different way I saw to integrate graphql with spring-boot project.
a) Provided by Kickstart community:
https://www.graphql-java-kickstart.com/
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
</dependency>
b) Provided by Spring-Boot community:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-graphql</artifactId>
</dependency>
I have following question on above?
a) What is difference between these two? Are they alternate to each other or we can use both?
b) Does library maintained by Kickstart community can be trusted for long term support?
c) What should we be using for production ready application?

Why does H2 database use Hibernate Core in Springboot application

I have a simple springboot application which uses H2 in memory db. I have used following dependency in my POM
spring-boot-starter-data-jpa
com.h2database.h2
When I start application, It automatically create Entity tables using Hibernate Dialect. I have no where mentioned about Hibernate in my POM. So why does this happening. Why Spring is using Hibernate Dialect. Do we have any option to change this dialect to some other dialect. please help.
Starter poms in the SpringBoot ecosystem bring a bag of dependencies, which have been tested and are proven to work together. It also saves you the hustle of managing the right dependencies versions.
You're using spring-boot-starter-data-jpa - which is a starter pom for JPA - the opinionated choice here is the usage of Hiberante as JPA provider.
If you look at the source of the pom file, you will see this definition:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<exclusions>
<exclusion>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
This is what brings hibernate to your project, although you have not explicitly declared it in your pom. The hibernate is downloaded as implicit dependency because of your spring-boot-starter-data-jpa starter pom.
Well you using "spring-boot-starter-data-jpa" and "starter" notion means that it has everythingfor it to work. If you would look to https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa/2.1.3.RELEASE , this dependency also includes hibernate-core.

What are the recommended JSF dependencies with TomEE1.7.x?

I've been developing a JSF2.0 (I'm not really sure about the JSF version) application on TomEE 1.7.3 (JavaEE6 based).
In my Maven pom.xml, I had too many dependencies which I've copied from many examples, but I reduced them to minimum requirements. Bellow is the "dependencies" part of my pom.xml:
<dependencies>
<!-- JavaEE6 -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
</dependency>
<!-- /JavaEE6 -->
<!-- OmniFaces for JSF, #Eager, postback same request parameters, etc. -->
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>1.8.3</version>
</dependency>
<!-- /OmniFaces -->
<!-- glassfish faces (is it called mojarra??) -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.12</version>
<scope>runtime</scope>
</dependency>
<!-- /glassfish faces -->
<!-- some mysql connector -->
<!-- some aws sdks, s3, ec2, etc -->
<!-- some apache commons, StringUtils. etc -->
<!-- some apache velocity -->
</dependencies>
The org.glassfish#javax.faces#2.2.12 dependency can be removed as well,
but it causes html layout problem (with the bootstrap css).
Downgrading it to version 2.0.x, causes the same layout problem.
I know I can fix it, but it takes couple of hours.
What I want to ask is:
Is it good or bad idea to use glassfish faces 2.2.x within TomEE1.7.x? TomEE's description says that it only supports up to JSF 2.0, but so far, it is working almost fine (I have few problems but those do not seem relevant to this version).
Is it better to remove glassfish faces dependency and use the default MyFaces instead?
Is it even better if I choose glassfish server, instead of TomEE, in my case?
BTW, I asked another question yesterday:
JSF2.0 Some facesmessages not sent to redirected page on error handling
and I recognized that I have to clean up my project first, so it might help reduce my problems.
Thank you.
As you already said yourself, TomEE is a Java EE 6 container (and not a barebones JSP/Servlet container like Tomcat). So it has already (nearly) everything from Java EE 6 provided out the box, including JSF 2.0/2.1. Nearly, because it's actually a Java EE web profile container. So you should actually use javaee-web-api artifact ID.
Only this should be sufficient:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
As an Apache product, its bundled JSF implementation is actually MyFaces, not Mojarra.
In case you intend to use JSF 2.2, which is part of Java EE 7, you should be using TomEE 7 instead and change the version in pom.
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
A milestone was released just this month, see the downloads page. Alternatives to TomEE 7 are WildFly 8+ or Payara 4+.
See also:
Our JSF wiki page - also contains JSF installation instructions and Maven coordinates (and many more useful information to get started).

spring-boot-starter versus spring-boot-starter-xxx

I noticed that the Spring Boot Sample Data Redis declares the following dependencies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
See here for full POM: https://github.com/spring-projects/spring-boot/blob/v1.0.0.RC4/spring-boot-samples/spring-boot-sample-data-redis/pom.xml
I see no mention of the <artifactId>spring-boot-starter-redis</artifactId>
My question is: when do I use spring-boot-starter versus spring-boot-starter-xxx where xxx is the name of the project (here Redis)?
The answer to the specific question: spring-boot-starter is a baseline for the others, and for standalone (non-web) apps that don't use any other Spring components - it has basic support for Spring, Logging, and Testing, but nothing else (no webapp features, no database etc.). Since all the other starters depend on it, once you use another one you can remove the vanilla starter. EDIT: see here https://github.com/spring-projects/spring-boot/commit/77fd127e09963a844f8fb4e574e1f0d9d3424d4e.
Up to you on the redis starter, but I would use the starter if it exists, since it will typically cut down on the number of dependencies you need to declare. The redis one actually doesn't add a lot of value (hence it didn't exist until recently), but it probably ought to be used in the sample.

Resources