zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Phalcon vs Spring 用法对照表(持续更新)

Springvs 用法 更新 持续 对照表 phalcon
2023-09-14 08:59:51 时间

FYI https://github.com/oscm/shell/blob/master/lang/php/pecl/phalcon.sh

You need to install with compiler, make tools.

 

#!/bin/sh

cd /usr/local/src/

git clone --depth=1 git://github.com/phalcon/cphalcon.git

cd cphalcon/build

./install

cat /srv/php/etc/conf.d/phalcon.ini EOF

extension=phalcon.so

 
1.2. Spring

You just only create a file as pom.xml, the maven will be fetch them.

 

 project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" 

 modelVersion 4.0.0 /modelVersion 

 groupId Spring /groupId 

 artifactId Spring /artifactId 

 version 0.0.1-SNAPSHOT /version 

 packaging war /packaging 

 dependencies 

 dependency 

 groupId org.springframework /groupId 

 artifactId spring-context /artifactId 

 version 4.1.1.RELEASE /version 

 /dependency 

 dependency 

 groupId org.springframework /groupId 

 artifactId spring-aop /artifactId 

 version 4.1.1.RELEASE /version 

 /dependency 

 dependency 

 groupId org.springframework /groupId 

 artifactId spring-webmvc /artifactId 

 version 4.1.1.RELEASE /version 

 /dependency 

 dependency 

 groupId org.springframework /groupId 

 artifactId spring-web /artifactId 

 version 4.1.1.RELEASE /version 

 /dependency 

 dependency 

 groupId javax.servlet /groupId 

 artifactId jstl /artifactId 

 version 1.2 /version 

 /dependency 

 dependency 

 groupId commons-logging /groupId 

 artifactId commons-logging /artifactId 

 version 1.1.3 /version 

 /dependency 

 /dependencies 

 build 

 sourceDirectory src /sourceDirectory 

 plugins 

 plugin 

 artifactId maven-compiler-plugin /artifactId 

 version 3.3 /version 

 configuration 

 source 1.6 /source 

 target 1.6 /target 

 /configuration 

 /plugin 

 plugin 

 artifactId maven-war-plugin /artifactId 

 version 2.6 /version 

 configuration 

 warSourceDirectory WebContent /warSourceDirectory 

 failOnMissingWebXml false /failOnMissingWebXml 

 /configuration 

 /plugin 

 /plugins 

 /build 

 /project 

 
2. Project initialization
* The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework $di = new \Phalcon\DI\FactoryDefault(); $di- set(dispatcher, function() use ($di) { $eventsManager = new EventsManager; $dispatcher = new Dispatcher; $dispatcher- setEventsManager($eventsManager); return $dispatcher; * The URL component is used to generate all kind of urls in the application $di- set(url, function() use ($config) { $url = new \Phalcon\Mvc\Url(); $url- setBaseUri($config- application- baseUri); return $url; * Setting up the view component $di- set(view, function() use ($config) { $view = new \Phalcon\Mvc\View(); $view- setViewsDir($config- application- viewsDir); return $view; * 数据库加密key $di- set(config, function() use ($config) { return $config;
* Database connection is created based in the parameters defined in the configuration file $di- set(db, function() use ($config) { return new \Phalcon\Db\Adapter\Pdo\Mysql(array( "host" = $config- database- host, "username" = $config- database- username, "password" = $config- database- password, "dbname" = $config- database- dbname * Start the session the first time some component request the session service $di- set(session, function() { $session = new \Phalcon\Session\Adapter\Files(); $session- start(); return $session; $di- set(session, function() use ($config) { $session = new Phalcon\Session\Adapter\Redis(array( path = sprintf("tcp://%s:%s?weight=1",$config- redis- host, $config- redis- port) $session- start(); return $session; * If the configuration specify the use of metadata adapter use it or use memory otherwise $di- set(modelsMetadata, function() use ($config) { if (isset($config- models- metadata)) { $metadataAdapter = Phalcon\Mvc\Model\Metadata\\.$config- models- metadata- adapter; return new $metadataAdapter(); } else { return new \Phalcon\Mvc\Model\Metadata\Memory(); * If the configuration specify the use of metadata adapter use it or use memory otherwise $di- set(modelsManager, function() { return new Phalcon\Mvc\Model\Manager();
?xml version="1.0" encoding="UTF-8"? web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0" display-name Spring /display-name welcome-file-list welcome-file index.html /welcome-file welcome-file index.htm /welcome-file welcome-file index.jsp /welcome-file welcome-file default.html /welcome-file welcome-file default.htm /welcome-file welcome-file default.jsp /welcome-file /welcome-file-list servlet servlet-name netkiller /servlet-name servlet-class org.springframework.web.servlet.DispatcherServlet /servlet-class load-on-startup 1 /load-on-startup /servlet servlet-mapping servlet-name netkiller /servlet-name url-pattern /welcome.jsp /url-pattern url-pattern /welcome.html /url-pattern url-pattern *.html /url-pattern /servlet-mapping /web-app

netkiller-servlet.xml

 

 beans xmlns="http://www.springframework.org/schema/beans"

 xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="

 http://www.springframework.org/schema/beans

 http://www.springframework.org/schema/beans/spring-beans.xsd

 http://www.springframework.org/schema/mvc

 http://www.springframework.org/schema/mvc/spring-mvc.xsd

 http://www.springframework.org/schema/context

 http://www.springframework.org/schema/context/spring-context.xsd" 

 context:component-scan base-package="cn.netkiller.controller" / 

 bean id="viewResolver"

 property name="viewClass"

 value="org.springframework.web.servlet.view.JstlView" / 

 property name="prefix" value="/WEB-INF/jsp/" / 

 property name="suffix" value=".jsp" / 

 /bean 

 /beans 

 
 


import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; @Controller public class Welcome { @RequestMapping("/welcome") public ModelAndView helloWorld() { String message = "Helloworld!!!"; return new ModelAndView("welcome", "message", message);
3.2. pathinfo

http://www.netkiller.cn/news/list/100.html

http://www.netkiller.cn/news/detail/100/1000.html

3.2.1. Phalcon
 

 ?php

class NewsController extends \Phalcon\Mvc\Controller


$this- view- setVar(category_id,$category_id); $this- view- setVar(article_id,$article_id);
3.2.2. Spring
 

package cn.netkiller.controller;

import org.springframework.stereotype.Controller;

import org.springframework.ui.ModelMap;

import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.servlet.ModelAndView;

@Controller

public class Pathinfo {

 @RequestMapping("/news/list/{category_id}")

 public ModelAndView urlTestId(@PathVariable String category_id) {

 return new ModelAndView("news/list", "category_id", category_id);

 @RequestMapping("/news/detail/{category_id}/{article_id}")

 public ModelAndView urlTestId(@PathVariable String category_id, @PathVariable String article_id) {

 ModelMap model = new ModelMap();

 model.addAttribute("category_id", category_id);

 model.addAttribute("article_id", article_id);

 return new ModelAndView("news/detail", model);

 
3.3. HTTP Get

http://www.netkiller.cn/member/login?email=netkiller@msn.com

3.3.1. Phalcon
 

 ?php

class MemberController extends ControllerBase

 public function loginAction()

 echo "email=" . $request- get("email");

 
3.3.2. Spring
 

package cn.netkiller.controller;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.servlet.ModelAndView;

@Controller

public class Welcome {

 @RequestMapping("/member/login")

 @ResponseBody

 public String getEmailWithRequestParam(@RequestParam("email") String email) {

 return "email=" + email;

 

如果参数很多写起来就非常辛苦

 

package cn.netkiller.controller;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.servlet.ModelAndView;

@Controller

public class Welcome {

 @RequestMapping("/member/login")

 @ResponseBody

 public String getEmailWithRequestParam(

 @RequestParam("email") String email

 @RequestParam("password") String password

 @RequestParam("ext") String ext

 
3.4. HTTP Post
echo "email=" . $request- getPost("email"); echo "password=" . $request- getPost("password"); echo "phone=" . $request- getPost("phone"); 3.4.2. Spring
 

package cn.netkiller.controller;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;

import org.springframework.ui.ModelMap;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.RequestParam;

import org.springframework.web.bind.annotation.ResponseBody;

import org.springframework.web.servlet.ModelAndView;

@Controller

public class Member {

 @RequestMapping("/http/form")

 public ModelAndView createCustomer(){

 ModelMap model = new ModelMap();

 model.addAttribute("email", "netkiller@msn.com");

 model.addAttribute("phone", "13113668890");

 return new ModelAndView("http/form", model);

 @RequestMapping(value= "/http/post", method = RequestMethod.POST)

 public ModelAndView saveCustomer(HttpServletRequest request, 

 @RequestParam(value="Email", required=false) String email, 

 @RequestParam(value="Password", required=false) String password, 

 @RequestParam(value="Phone", required=false) String phone){

 ModelMap model = new ModelMap();

 model.addAttribute("email", email);

 model.addAttribute("password", password);

 model.addAttribute("phone", phone);

 return new ModelAndView("http/post", model);

 
4. View
 

 !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" 

 html 

 head 

 meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" 

 title Insert title here /title 

 /head 

 body 

 ?php echo ${message} ? 

 /body 

 /html 

 
4.1.2. Spring
 

 %@ page language="java" contentType="text/html; charset=ISO-8859-1"

 pageEncoding="ISO-8859-1"% 

 %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"% 

 !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" 

 html 

 head 

 meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" 

 title Insert title here /title 

 /head 

 body 

 ${message}

 /body 

 /html 

 
4.2. Array
 

 !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" 

 html 

 head 

 meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" 

 title Insert title here /title 

 /head 

 body 

 ?php foreach($books as $book) {? 

 ?php echo $book ? br 

 ?php } ? 

 /body 

 /html 

 
4.2.2. Spring
 

 %@ page language="java" contentType="text/html; charset=ISO-8859-1"

 pageEncoding="ISO-8859-1"% 

 %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"% 

 !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" 

 html 

 head 

 meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" 

 title Insert title here /title 

 /head 

 body 

 c:forEach items="${books}" var="book" 

 c:out value="${book}" /c:out br 

 /c:forEach 

 /body 

 /html 

 
4.3. Map or Hashmap
 

 !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" 

 html 

 head 

 meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" 

 title Insert title here /title 

 /head 

 body 

 ?php foreach($books as $key= $value) {? 

 ?php echo $key ? : ?php echo $value ? br 

 ?php } ? 

 /body 

 /html 

 
4.3.2. Spring
 

 %@ page language="java" contentType="text/html; charset=utf-8"

 pageEncoding="utf-8"% 

 %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"% 

 !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" 

 html 

 head 

 meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" 

 title Insert title here /title 

 /head 

 body 

 c:forEach items="${books}" var="book" 

 c:out value="${book.key}" /c:out : c:out value="${book.value}" /c:out br 

 /c:forEach 

 /body 

 /html 

 
4.4. From
?php= $this- tag- textField("name") ? ?php echo $this- tag- passwordField(array("password", "size" = 30)) ? ?php echo $this- tag- select(array("status", array("A" = "Active","I" = "Inactive")));? ?php echo $this- tag- textArea(array("aboutYou","","cols" = "6","rows" = 20)) ? ?php echo $this- tag- hiddenField(array("parent_id","value"= "5")) ? ?= $this- tag- submitButton("Register"); ? ?php = $this- tag- endForm() ? /body /html 4.4.2. Spring
 

 %@ taglib uri="http://www.springframework.org/tags/form" prefix="form"% 

 html 

 head 

 title Registration Page /title 

 /head 

 body 

 form:form method="POST" commandName="user" 

 form:input path="name" / 

 form:password path="password" / 

 form:radiobutton path="gender" value="M" label="M" / 

 form:radiobutton path="gender" value="F" label="F" / 

 form:select path="country" 

 form:option value="0" label="Select" / 

 form:options items="${countryList}" itemValue="countryId" itemLabel="countryName" / 

 /form:select 

 form:textarea path="aboutYou" / 

 form:checkboxes path="communityList" items="${communityList}" itemValue="key" itemLabel="value" / 

 form:checkbox path="mailingList" label="Would you like to join our mailinglist?" / 

 input type="submit" value="Register" 

 /form:form 

 /body 

 /html 

 
5. Model

Maven 增加mybatis与MySQL依赖设置

 

 project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" 

 modelVersion 4.0.0 /modelVersion 

 groupId MyBatis /groupId 

 artifactId MyBatis /artifactId 

 version 0.0.1-SNAPSHOT /version 

 dependencies 

 dependency 

 groupId junit /groupId 

 artifactId junit /artifactId 

 version 3.8.1 /version 

 scope test /scope 

 /dependency 

 dependency 

 groupId org.mybatis /groupId 

 artifactId mybatis /artifactId 

 version 3.3.0 /version 

 /dependency 

 dependency 

 groupId mysql /groupId 

 artifactId mysql-connector-java /artifactId 

 version 5.1.37 /version 

 /dependency 

 /dependencies 

 build 

 sourceDirectory src /sourceDirectory 

 plugins 

 plugin 

 artifactId maven-compiler-plugin /artifactId 

 version 3.3 /version 

 configuration 

 source 1.8 /source 

 target 1.8 /target 

 /configuration 

 /plugin 

 /plugins 

 /build 

 /project 

 

mybatis.xml

 

 ?xml version="1.0" encoding="UTF-8"? 

 !DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd" 

 configuration 

 environments default="development" 

 environment id="development" 

 transactionManager type="JDBC" / 

 !-- 配置数据库连接信息 -- 

 dataSource type="POOLED" 

 property name="driver" value="com.mysql.jdbc.Driver" / 

 property name="url" value="jdbc:mysql://192.168.6.1:3306/mybatis" / 

 property name="username" value="mybatis" / 

 property name="password" value="mybatis" / 

 /dataSource 

 /environment 

 /environments 

 mappers 

 mapper resource="cn/netkiller/mapping/userMapping.xml" / 

 /mappers 

 /configuration 

 

cn/netkiller/mapping/userMapping.xml

 

 ?xml version="1.0" encoding="UTF-8"? 

 !DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" 

 mapper namespace="cn.netkiller.mapping.UserMapping" 

 select id="getUser" parameterType="String" resultType="cn.netkiller.model.User" 

 select * from user where id=#{id}

 /select 

 /mapper 

 

数据类型映射

 

package cn.netkiller.model;

public class User {

 private String id;

 private String name;

 private int age;

 public String getId() {

 return id;

 public void setId(String id) {

 this.id = id;

 public String getName() {

 return name;

 public void setName(String name) {

 this.name = name;

 public int getAge() {

 return age;

 public void setAge(int age) {

 this.age = age;

 @Override

 public String toString() {

 return "User [id=" + id + ", name=" + name + ", age=" + age + "]";


import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; import cn.netkiller.model.*; public class Test { public static void main(String[] args) { // TODO Auto-generated method stub String resource = "mybatis.xml"; InputStream is = Tests.class.getClassLoader().getResourceAsStream(resource); SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(is); SqlSession session = sessionFactory.openSession(); String statement = "cn.netkiller.mapping.UserMapping.getUser";// 映射sql的标识字符串 User user = session.selectOne(statement, "2"); System.out.println(user.toString());
6. Session
import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.view.RedirectView; import cn.netkiller.*; @Controller public class Http { @RequestMapping("/session") @ResponseBody public String home(HttpServletRequest request) { return "" + request.getSession().getCreationTime(); @RequestMapping("/session/set") @ResponseBody public String setSession(HttpSession session) { String username = "netkiller"; session.setAttribute("username", username); return username; @RequestMapping("/session/get") @ResponseBody public String getSession(HttpSession session) { String username = (String) session.getAttribute("username"); return username; @RequestMapping("/session/remove") @ResponseBody public String removeSession(HttpSession session) { session.removeAttribute("username"); String username = (String) session.getAttribute("username"); return username; @RequestMapping("/session/invalidate") @ResponseBody public String invalidateSession(HttpSession session) { session.invalidate(); return "invalidate";
// inject the template as ListOperations // can also inject as Value, Set, ZSet, and HashOperations @Resource(name="redisTemplate") private ListOperations String, String listOps; public void addLink(String userId, URL url) { listOps.leftPush(userId, url.toExternalForm()); // or use template directly redisTemplate.boundListOps(userId).leftPush(url.toExternalForm()); 7.2. Model + Cache
$articles = Article::find(array( "cache" = array("service"= redis, "key" = $key, "lifetime" = 60) 7.2.2. MyBatis

MyBatis Redis Cache adapter http://mybatis.github.io/redis-cache

pom.xml

 

 dependencies 

 | Provided dependencies

 dependency 

 groupId org.mybatis /groupId 

 artifactId mybatis /artifactId 

 version 3.3.0 /version 

 scope provided /scope 

 /dependency 

 | compile dependencies

 dependency 

 groupId redis.clients /groupId 

 artifactId jedis /artifactId 

 version 2.7.3 /version 

 scope compile /scope 

 /dependency 

 /dependencies 

 
 

 
 

 
 

 
 

 
7.3. Phalcon vs Ehcache

Output

{"contact":{"name":"Neo","website":"http:\/\/www.netkiller.cn","nickname":"netkiller"}}

 

Decode

 

 ?php

$string = {"contact":{"name":"Neo","website":"http:\/\/www.netkiller.cn","nickname":"netkiller"}};

print_r(json_decode($string));

 

输出

 

stdClass Object

 [contact] = stdClass Object

 [name] = Neo

 [website] = http://www.netkiller.cn

 [nickname] = netkiller

 
8.2. Spring

JSON 编码

 

package netkiller.json;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.OutputStream;

import javax.json.*;

public final class Writer {

 public static void main(String[] args) {

 // TODO Auto-generated method stub

 JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();

 JsonObjectBuilder addressBuilder = Json.createObjectBuilder();

 JsonArrayBuilder phoneNumBuilder = Json.createArrayBuilder();

 phoneNumBuilder.add("12355566688").add("0755-2222-3333");

 addressBuilder.add("street", "Longhua").add("city", "Shenzhen").add("zipcode", 518000);

 jsonBuilder.add("nickname", "netkiller").add("name", "Neo").add("department", "IT").add("role", "Admin");

 jsonBuilder.add("phone", phoneNumBuilder);

 jsonBuilder.add("address", addressBuilder);

 JsonObject jsonObject = jsonBuilder.build();

 System.out.println(jsonObject);

 try {

 // write to file

 File file = new File("json.txt");

 if (!file.exists()) {

 file.createNewFile();

 OutputStream os = null;

 os = new FileOutputStream(file);

 JsonWriter jsonWriter = Json.createWriter(os);

 jsonWriter.writeObject(jsonObject);

 jsonWriter.close();

 } catch (IOException e) {

 // TODO Auto-generated catch block

 e.printStackTrace();

运行后输出

{"nickname":"netkiller","name":"Neo","department":"IT","role":"Admin","phone":["12355566688","0755-2222-3333"],"address":{"street":"Longhua","city":"Shenzhen","zipcode":"518000"}}

 

JSON 解码

 

package netkiller.json;

import java.io.FileInputStream;

import java.io.IOException;

import java.io.InputStream;

import javax.json.Json;

import javax.json.JsonArray;

import javax.json.JsonObject;

import javax.json.JsonReader;

import javax.json.JsonValue;

public final class Reader {

 public static final String JSON_FILE="json.txt";

 public static void main(String[] args) throws IOException {

 InputStream fis = new FileInputStream(JSON_FILE);

 //create JsonReader object

 JsonReader jsonReader = Json.createReader(fis);

 //get JsonObject from JsonReader

 JsonObject jsonObject = jsonReader.readObject();

 //we can close IO resource and JsonReader now

 jsonReader.close();

 fis.close();

 System.out.printf("nickname: %s \n", jsonObject.getString("nickname"));

 System.out.printf("name: %s \n", jsonObject.getString("name"));

 System.out.printf("department: %s \n", jsonObject.getString("department"));

 System.out.printf("role: %s \n", jsonObject.getString("role"));

 JsonArray jsonArray = jsonObject.getJsonArray("phone");

 //long[] numbers = new long[jsonArray.size()];

 int index = 0;

 for(JsonValue value : jsonArray){

 //numbers[index++] = Long.parseLong(value.toString());

 System.out.printf("phone[%d]: %s \n", index++, value.toString());

 //reading inner object from json object

 JsonObject innerJsonObject = jsonObject.getJsonObject("address");

 System.out.printf("address: %s, %s, %d \n", innerJsonObject.getString("street"), innerJsonObject.getString("city"), innerJsonObject.getInt("zipcode"));

nickname: netkiller 

name: Neo 

department: IT 

role: Admin 

phone[0]: +8612355566688 

phone[1]: 0755-2222-3333 

address: Longhua, Shenzhen, 518000

 
9. Message Queue
Spring系列(十一):@Profile 注解用法介绍 在Spring容器中如果存在同一类型的多个组件,可以使用@Profile注解标识实际要获取的是哪一个bean,这在不同的环境使用不同的变量的场景下非常有用。 最典型的例子:开发环境、测试环境、生产环境会配置不同的数据源,在尽量不修改代码的情况下,可以使用这个注解来动态指定要连接的数据源。
Spring系列(八):Spring生命周期中BeanPostProcessor接口用法介绍 BeanPostProcessor接口通常被称为Bean的后置处理器,它是Spring中定义的接口,可以在Spring容器的创建过程中(主要在Bean初始化前后进行工作)回调BeanPostProcessor中定义的两个方法。
Spring系列(七):@FactoryBean注解用法介绍 FactoryBean是实现了FactoryBean T 接口的Bean,可以该Bean的ID从BeanFactory中获取的实际上是FactoryBean中getObject()方法返回的实例对象,而并不是直接FactoryBean本身,想要获取FactoryBean对象本身,可以在id前面加一个 符号来获取
Spring系列(六):@Conditional注解用法介绍 @Conditional是Spring4版本新提供的一种注解,它的作用是按照设定的条件进行判断,把满足判断条件的bean注册到Spring容器。
Spring系列(五):@Lazy懒加载注解用法介绍 @Lazy 懒加载注解的概念 SpringIoC容器会在启动的时候实例化所有单实例 bean 。如果我们想要实现 Spring 在启动的时候延迟加载 bean,即在首次调用bean的时候再去执行初始化,就可以使用 @Lazy 注解来解决这个问题
Spring系列(四):@Scope注解用法介绍 @Scope注解主要作用是调节Ioc容器中的作用域,在Spring IoC容器中主要有以下五种作用域:基本作用域:singleton(单例)、prototype(多例);Web 作用域(reqeust、session、globalsession),自定义作用域。
netkiller Nickname:netkiller | English name: Neo chen | QQ: 291379 | 订阅号:netkiller-ebook | 网站:http://www.netkiller.cn
阿里特邀专家徐雷Java Spring Boot开发实战系列课程(第18讲):制作Java Docker镜像与推送到DockerHub和阿里云Docker仓库 立即下载