I get new domain sunspring,and I more like this domain that springblog.I think springblog is too rigid,I've been contemplating this change for quite some time now. rest assured, that while the domain of the blog has changed, the old springblog.one will reserved until 8/1. After august, will 301 to sunspring.welcome to visit sunspring.cc.
I am recently very interested in the Golang and will temporarily stop updating Springblog.
For a Spring Boot Web project, a major dependency sign is the spring-boot-starter-web starter. The spring-boot-starter-web module does not actually have code in Spring Boot, but is only in pom.xml. It carries some dependencies, including web, webmvc and tomcat, etc. for example:Create a new SpringBoot-Web project. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> Click pom.xml and find there have dependencies of tomcat <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <version>3.2.2.RELEASE</version> <scope>compile</scope> </dependency> Exploring step by step from the Spring Boot startup entry point run method public static ConfigurableApplicationContext run(Class primarySource, String… args) { return run(new Class[] { primarySource }, args); } // Continue clicking into the run method public static ConfigurableApplicationContext run(Class<?>[] primarySources, String[] args) { return new SpringApplication(primarySources).run(args); } After entering this run method, we can see some familiar initialization events. The main process is also completed here. The code flow is roughly as follows: /** * Run the Spring application, creating and refreshing a new * {@link ApplicationContext}. * @param args the application arguments (usually passed from a Java main method) * @return a running {@link ApplicationContext} */ public ConfigurableApplicationContext…
SpringBoot has three built-in Servlet containers, Tomcat, Jetty, and undertow. We only need a Java running environment to run SpringBoot projects, and SpringBoot projects can be packaged into a jar package. And SpringBoot uses JavaConfig to configure Spring and provides a large number of annotations, which greatly improves work efficiency. For example, @Configuration is combined with @bean annotations, class scanning is completed based on @Configuration, and return values are injected into IOC based on @bean annotations. container,and integrates commonly used dependency groups and merges them into one dependency, so that it can be added to the project's Maven or Gradle build at once. It is make springboot to easy to use. I am used to using the application.yaml configuration file YAML file format is a JSON superset file format supported by Spring Boot. It is data-centered and is more advanced than properties, xml, etc. Suitable for configuration files. Compared with xml, yml lacks some structured code, making the data more direct and clear at a glance. And More concise than properties files,And I like the…
Introduction to Spring Boot When I first started learning JavaWeb, I used Servlet/JSP for development. It was a headache to create a Servlet for each interface. Later, I found ways like hidden fields or reflection to reduce the creation of Servlets, but it was still inconvenient. Then, I introduced frameworks like Struts2/SpringMVC to simplify our development. Compared to Servlet/JSP, productivity did improve significantly after introducing the framework. However, after using it for a while, I discovered new problems, such as cumbersome and error-prone configuration. When starting a new project, I had to set up the environment, and it always involved a few lines of configuration. The only difference between different projects might be the package, while most of the other configurations remained the same. Java has always been criticized for its cumbersome configuration and large code volume, and this is one of its manifestations. So what can I do? Spring Boot came into being. Spring Boot mainly provides the following functionalities: It offers a convenient and quick entry experience for all Spring-based Java development. It…
Spring mvc is the Spring MVC framework. Can you briefly introduce how to use it It's very simple, it's about creating a Project&Module, importing static pages, creating package structures (controller, service, dao, domain, utils), and creating configuration files (applicationContext.xml, spring mvc.ml, jdbc. properties, log4j. properties) The configuration file is basically like this: ApplicationContext.xml: This is the core configuration file of the Spring framework, used to define the beans of an application and their dependencies, AOP, transaction management, etc. It is responsible for the configuration and initialization of the entire application, including the configuration information of the Spring container. Spring-mvc.xml: This is the configuration file for the Spring MVC framework, used to configure Web MVC related components such as processor mappers, view parsers, interceptors, etc. It will be introduced in the web.xml file through<Servlet>and<Servlet mapping>elements and integrated with the Spring container. Dbc.properties: This is a database connection configuration file used to configure database connection information, such as database URL, username, password, etc. In Spring applications, configuration information for database connections can be obtained by reading this…
Maven is a Java tool for project management. In Java, you can using Maven to conveniently manage collaborative projects and libraries, making it easier for team members to build java project. Download Maven. you can download Maven in page: http://maven.apache.org/download.html. It contains various versions of Maven download files. System Requirements: Java Development Kit (JDK): Maven 3.9+ requires JDK 8 or above to execute. It still allows you to build against JDK 1.3 and other versions using toolchains. Memory: No minimum requirement. Disk Space: Approximately 10MB is required for the Maven installation itself. Additionally, disk space will be used for your local Maven repository. The size of the local repository may vary depending on usage, but expect at least 500MB. Operating System: No minimum requirement. Start-up scripts are included as shell scripts (tested on various Unix flavors) and Windows batch files. I downloaded: apache-maven-3.9.6-bin.tar.gz for example Extract the Maven archive. Extract the apache-maven-3.9.6-bin.tar.gz file and move the extracted apache-maven folder to like :D:\Maven. If the Maven folder does not exist, you should create it. Set the…
Spring is a useful framework for quickly building web applications. I do like it. Spring requires a Java environment, so you need to install Java first. You can usually download Java java.com(Oracle Java), but I don't like Oracle (even though it's still free for developers). I recommend installing OpenJDK instead: https://openjdk.org/install/. Manual installation of Java: I don't like automatic installation, so let me explain manual installation. Unzip the JDK directory and modify the values of the PATH and JAVA_HOME environment variables. Usually, it's the path to the "jdk/bin" directory (the bin directory under the JDK installation directory). On Windows systems, when developing, right-click "My Computer," select "Properties" -> "Advanced" -> "Environment Variables," and modify the PATH value to include "jdk/bin." On Linux systems, for example, if the JDK is installed in "/usr/local/jdk." Add the following two variables:PATH=/usr/local/jdk/bin:$PATHJAVA_HOME=/usr/local/jdk Spring download: You can download the framework from the official website: https://spring.io/.For beginners, I recommend directly downloading the pre-compiled package (Spring framework is a series of JAR files. By importing the JAR files, you can use Spring):https://spring.io/projects/spring-framework You…
Nice to see you, WordPress. This is first post. but I don't like block editor.