Java EE vs Spring. Or:what is a standard?
What is Java EE
The Java EE is a platform for a range of technical standards.
Java EE includes implementations of a range of standards (interfaces).
If you're going to use these interfaces, I'm afraid to use a Java EE server instead of just a servlet container
Servlet-api
How servlet registration is performed
Because Tom Cat realizes Servlet-api, so it knows how to find the Web. xml file.
JPA specification
For Tomcat, he doesn't implement the JPA specification, so when you really want to implement database access in your Web App
- You can simply use JDBC, which is unrestricted, because JDBC is not a Java EE thing that everyone can use, and JDBC is just a database connection
Take a look at the interface that SQLite implements
public static final Java.lang.String PREFIX = "Jdbc:sqlite:";p ublic class JDBC implements Java.sql.Driver {public stat IC final java.lang.String PREFIX = "Jdbc:sqlite:"; Public JDBC () {/* Compiled code */} public int getmajorversion () {/* Compiled code */} public int Getminorversio N () {/* Compiled code */} public boolean jdbccompliant () {/* Compiled code */} public boolean Acceptsurl (java.la Ng. String URL) {/* Compiled code */} public static Boolean isvalidurl (java.lang.String URL) {/* Compiled code */} p Ublic java.sql.driverpropertyinfo[] getpropertyinfo (java.lang.String URL, java.util.Properties info) throws java.sql.SQLException {/* Compiled code */} public java.sql.Connection connect (java.lang.String URL, java.util.Proper Ties info) throws Java.sql.SQLException {/* Compiled code */} static java.lang.String ExtractAddress (java.lang.String URL) {/* Compiled code */} public static java.sql.Connection createconnection (java.lang.String urL, Java.util.Properties prop) throws Java.sql.SQLException {/* Compiled code */}}
- Be sure to use JPA, you can refer to this article
JDBC Change JPA
The main tasks for JDBC to access a database include:
- Get the JDBC driver;
- Use Drivermanager,connection,statement,resultset, etc.;
The operations that use JPA to complete data include:
- Get the JDBC driver;
- Get the relevant class library and configuration file of persistence provider;
- provide entity classes;
- Use interfaces such as persistence, entitymanagerfactory, and entity.
While industry is similar to the JPA specification, there are hibernate
Spring
So the question is, what does spring rely on for Java EE specifications?
Spring relies only on SERVLET-API.
however , the extensibility of spring is outrageous, and for implementing the JPA specification, he has spring Data JPA,
It relies on OPENJPA-PERSISTENCE-JDBC, and OPENJPA implements the JSR-317 Java Persistence 2.0 specification, so it can still be used in Tomcat. Note that the JPA specification uses the Persitence.xml configuration file, which is a good understanding, with Web. Xml.
Look back, if you don't want to use JPA, you can use spring's own jdbctemplate, which is in Org.springframework.jdbc.core.
Summarize
The core of spring is still CDI, and it is for this reason that even if it does not implement most of the Java EE specifications, it can also be compatible with the implementation of these specifications, and then use CDI to inject these implementations.
Understanding is not comprehensive enough, I hope we can change this article later.
The relationship between Spring and Java EE