最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Mybatis逆工程jar包的修改和打包

 更新時間:2016年06月06日 14:19:30   作者:安度因  
這篇文章主要介紹了Mybatis逆工程jar包的修改和打包的相關(guān)資料,需要的朋友可以參考下

上一篇文章Mybatis逆工程的使用主要是講了mybatis-generator-core-1.3.2.jar的使用,這一篇我要介紹的是,修改jar包代碼,實現(xiàn)生成自定義模板。

1.我們從這里可以下載mybatis-generator-core-1.3.2.jar項目源碼

http://maven.outofmemory.cn/org.mybatis.generator/mybatis-generator-core/1.3.2/

2.在eclipse下導(dǎo)入存在的maven項目,F(xiàn)ile->Import

選擇項目源碼位置,點finish完成導(dǎo)入。

項目目錄結(jié)構(gòu)大概這樣子。

3.下面我逆工程要生成的mapping和xml格式。

4.開始修改,首先說明一下各目錄

最底邊的tse包是我自定義的包,里面是個主類,測試生成的代碼是否達到預(yù)期標準。

由于這個架包是老外寫的,生成的代碼風(fēng)格和我們不大一一樣,如果你想修改代碼格式,建議你看一下菠蘿大象的文章,我這里就不講代碼格式了。

http://www.blogjava.net/bolo/archive/2015/03/20/423683.html

首先,我們先修改逆工程要生成的接口文件mapping的代碼,默認情況下有增刪改查,我們講其中一個改方法update吧

比如 我要讓生成的mapping中有這樣的一個方法 void update(Map<String, Object> dataMap);

就修改org.mybatis.generator.codegen.mybatis3.javamapper.elements包下的UpdateByPrimaryKeyWithoutBLOBsMethodGenerator類,如下:

/*
* Copyright 2009 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mybatis.generator.codegen.mybatis3.javamapper.elements;
import java.util.Set;
import java.util.TreeSet;
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.api.dom.java.JavaVisibility;
import org.mybatis.generator.api.dom.java.Method;
import org.mybatis.generator.api.dom.java.Parameter;
/**
* 
* @author Jeff Butler
* 
*/
public class UpdateByPrimaryKeyWithoutBLOBsMethodGenerator extends
AbstractJavaMapperMethodGenerator {
public UpdateByPrimaryKeyWithoutBLOBsMethodGenerator() {
super();
}
@Override
public void addInterfaceElements(Interface interfaze) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
FullyQualifiedJavaType parameterType = new FullyQualifiedJavaType(
introspectedTable.getBaseRecordType());
importedTypes.add(parameterType);
//新增一個方法
Method method = new Method();
//添加方法修飾符PUBLIC
method.setVisibility(JavaVisibility.PUBLIC);
//設(shè)置返回值,這里我用的是自定義的void,無返回值方法 getVoidInstance()
//FullyQualifiedJavaType類中可以自定義返回值方法,大家可以自己進去添加
//不想那么麻煩的話,可以 new FullyQualifiedJavaType("void") , 構(gòu)造函數(shù)寫上返回類型就行了
method.setReturnType(FullyQualifiedJavaType.getVoidInstance());
//設(shè)置方法名,同樣可以自己進去看
method.setName(introspectedTable.getUpdateByPrimaryKeyStatementId());
//method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
FullyQualifiedJavaType mapType=FullyQualifiedJavaType.getMyMapInstance();
//方法的參數(shù),這里是Map類型的dateMap參數(shù)
Parameter parameter = new Parameter(mapType, "dataMap");
method.addParameter(parameter);
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
addMapperAnnotations(interfaze, method);
if (context.getPlugins()
.clientUpdateByPrimaryKeyWithoutBLOBsMethodGenerated(method,
interfaze, introspectedTable)) {
interfaze.addImportedTypes(importedTypes);
interfaze.addMethod(method);
}
}
public void addMapperAnnotations(Interface interfaze, Method method) {
return;
}
} 

大家可以根據(jù)注釋來修改。

接下來修改mapping對應(yīng)的xml中的代碼,同樣的,這里我只介紹修改update方法,相信看完你就能自己修改其它方法。

就修改org.mybatis.generator.codegen.mybatis3.xmlmapper.elements包下的UpdateByPrimaryKeyWithoutBLOBsElementGenerator類,如下:

/*
* Copyright 2009 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mybatis.generator.codegen.mybatis3.xmlmapper.elements;
import java.util.Iterator;
import java.util.List;
import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.dom.OutputUtilities;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement;
import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities;
/**
* 
* @author Jeff Butler
* 
*/
public class UpdateByPrimaryKeyWithoutBLOBsElementGenerator extends
AbstractXmlElementGenerator {
//private boolean isSimple;
public UpdateByPrimaryKeyWithoutBLOBsElementGenerator(boolean isSimple) {
super();
//this.isSimple = isSimple;
}
@Override
public void addElements(XmlElement parentElement) {
//update標簽(方法最外層)
XmlElement answer = new XmlElement("update"); //$NON-NLS-1$
//update標簽的屬性
answer.addAttribute(new Attribute(
"id", introspectedTable.getUpdateByPrimaryKeyStatementId())); //$NON-NLS-1$
answer.addAttribute(new Attribute("parameterType", //$NON-NLS-1$
"Map"));
//把標簽加進去
context.getCommentGenerator().addComment(answer);
StringBuilder sb = new StringBuilder();
sb.append("update "); //$NON-NLS-1$
sb.append(introspectedTable.getFullyQualifiedTableNameAtRuntime());
//標簽內(nèi)容,即文本元素
answer.addElement(new TextElement(sb.toString()));
sb.setLength(0);
//set標簽
XmlElement setElement = new XmlElement("set"); //$NON-NLS-1$
//獲取數(shù)據(jù)庫表中的所有字段
List <IntrospectedColumn> cols=introspectedTable.getAllColumns();
//迭代
java.util.Iterator<IntrospectedColumn> iter =cols.iterator();
while (iter.hasNext()) {//迭代
//迭代到某一字段
IntrospectedColumn introspectedColumn = iter.next();
//if標簽
XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$
//字段名
String str=MyBatis3FormattingUtilities
.getEscapedColumnName(introspectedColumn);
//if標簽添加屬性test,值為 字段 !=null and 字段!=''
ifElement.addAttribute(new Attribute("test",str+" != null and "+str+"!='' "));
//if標簽內(nèi)容 ,文本元素,給字段賦予即將修改的值
sb.append(MyBatis3FormattingUtilities
.getEscapedColumnName(introspectedColumn));
sb.append(" = "); //$NON-NLS-1$
sb.append(MyBatis3FormattingUtilities
.getParameterClause(introspectedColumn));
if (iter.hasNext()) {
sb.append(',');
}
//if標簽添加上面的文本元素
ifElement.addElement(new TextElement(sb.toString()));
if (iter.hasNext()) {
sb.setLength(0);
OutputUtilities.xmlIndent(sb, 1);
}
setElement.addElement(ifElement);
}
//where元素(修改的字段前提條件)
XmlElement whereElement =new XmlElement("where");
for (IntrospectedColumn introspectedColumn : introspectedTable
.getPrimaryKeyColumns()) {//遍歷表中字段進行判斷
sb.setLength(0);
sb.append(MyBatis3FormattingUtilities
.getEscapedColumnName(introspectedColumn));
sb.append(" = "); //$NON-NLS-1$
sb.append(MyBatis3FormattingUtilities
.getParameterClause(introspectedColumn));
whereElement.addElement(new TextElement(sb.toString()));
}
//方法中最外層xml元素 update元素添加set元素和where元素
answer.addElement(setElement);
answer.addElement(whereElement);
if (context.getPlugins()
.sqlMapUpdateByPrimaryKeyWithoutBLOBsElementGenerated(answer,
introspectedTable)) {
parentElement.addElement(answer);
}
}
} 

其它方法大家可以根據(jù)這個update方法改。

如果要添加新方法的話參考下面這個帖子

http://m.blog.csdn.net/article/details?id=35985705

下面我來驗證修改成果

generatorConfig.xml //先配置xml 放在src/main/resources/ 目錄下
<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" > 
<generatorConfiguration> 
<!-- 引入配置文件 --> 
<!-- 指定數(shù)據(jù)連接驅(qū)動jar地址 --> 
<classPathEntry location="E:\eclipse_workspace\testMybatis\mysql-connector-java-5.1.13-bin.jar" /> 
<!-- 一個數(shù)據(jù)庫一個context --> 
<context id="infoGuardian" targetRuntime="MyBatis3"> 
<!-- 注釋 --> 
<commentGenerator > 
<property name="suppressAllComments" value="true"/><!-- 是否取消注釋 --> 
<property name="suppressDate" value="true" /> <!-- 是否生成注釋代時間戳--> 
</commentGenerator> 
<!-- jdbc連接 --> 
<jdbcConnection driverClass="com.mysql.jdbc.Driver" 
connectionURL="jdbc:mysql://localhost:3306/login?characterEncoding=UTF-8" userId="root" 
password="root" /> 
<!-- 類型轉(zhuǎn)換 --> 
<javaTypeResolver> 
<!-- 是否使用bigDecimal, false可自動轉(zhuǎn)化以下類型(Long, Integer, Short, etc.) --> 
<property name="forceBigDecimals" value="false"/> 
</javaTypeResolver> 
<!-- 生成實體類地址 --> 
<javaModelGenerator targetPackage="pojo" 
targetProject="mybatis3" > 
<!-- 是否在當前路徑下新加一層schema,eg:fase路徑cn.ffcs.test.domain", true:cn.ffcs.test.domain".[schemaName] --> 
<property name="enableSubPackages" value="true"/> 
<!-- 是否針對string類型的字段在set的時候進行trim調(diào)用 --> 
<property name="trimStrings" value="true"/> 
</javaModelGenerator> 
<!-- 生成mapxml文件 --> 
<sqlMapGenerator targetPackage="mapper" 
targetProject="mybatis3" > 
<!-- 是否在當前路徑下新加一層schema,eg:fase路徑cn.ffcs.test.domain", true:cn.ffcs.test.domain".[schemaName] --> 
<property name="enableSubPackages" value="true" /> 
</sqlMapGenerator> 
<!-- 生成mapxml對應(yīng)client,也就是接口dao --> 
<javaClientGenerator type="XMLMAPPER" targetPackage="mapper" 
targetProject="mybatis3"> 
<!-- 是否在當前路徑下新加一層schema,eg:fase路徑cn.ffcs.test.domain", true:cn.ffcs.test.domain".[schemaName] --> 
<property name="enableSubPackages" value="true" /> 
</javaClientGenerator> 
<!-- 配置表信息,這里沒生成一張表,這里需要改變一次對應(yīng)表名 --> 
<table tableName="login" 
domainObjectName="Login" enableCountByExample="false" 
enableDeleteByExample="false" enableSelectByExample="false" 
enableUpdateByExample="false"> 
</table> 
</context> 
</generatorConfiguration> 

StartUp.java//驗證的主程序

package tse;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;
public class StartUp {
public static void main(String []args)throws Exception{
List<String> warnings = new ArrayList<String>();
File configFile=new File(StartUp.class.getResource("/generatorConfig.xml").toURI());
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(configFile);
DefaultShellCallback shellCallback = new DefaultShellCallback(true);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null);
System.out.println(warnings);
}
} 

好了,運行StartUp.java

就根據(jù)generatorConfig.xml的配置在目標目錄生成對應(yīng)文件。

OK,和我預(yù)期結(jié)果一樣。

5.上面修改完了,我們開始打包。

由于是個maven項目,我用的是maven3.3.9,大家也可以用eclipse內(nèi)置的maven,反正我是不喜歡。

下面是我maven項目的pom.xml文件代碼

<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2009-2011 The MyBatis Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
version: $Id: pom.xml 4114 2011-11-27 19:03:32Z simone.tripodi $
-->
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator</artifactId>
<version>1.3.2</version>
</parent>
<artifactId>mybatis-generator-core</artifactId>
<packaging>jar</packaging>
<name>MyBatis Generator Core</name>
<build>
<!-- this build creates and installs an instrumented JAR file
for use by the systests projects - so we can gather
consolidated coverage information
-->
<plugins>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>site</goal>
</goals>
</execution>
</executions>
</plugin> -->
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin> -->
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<includes>
<include>**/org/**</include>
</includes>
</configuration>
</execution>
</executions>
</plugin> -->
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin> -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<executions>
<execution>
<id>cobertura-instrument</id>
<phase>pre-integration-test</phase>
<goals>
<goal>instrument</goal>
</goals>
</execution>
</executions> 
</plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.mybatis.generator.api.ShellRunner</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>cobertura-jar</id>
<phase>integration-test</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>cobertura</classifier>
<classesDirectory>${basedir}/target/generated-classes/cobertura</classesDirectory>
</configuration>
</execution>
</executions>
</plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>attach-jar</id>
<phase>integration-test</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix></classpathPrefix>
<mainClass>org.mybatis.generator.api.ShellRunner</mainClass>
</manifest>
</archive>
<includes>
<include>**/org/**</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>cobertura-install</id>
<phase>integration-test</phase>
<goals>
<goal>install</goal>
</goals>
<configuration>
<classifier>cobertura</classifier>
</configuration>
</execution>
</executions> 
</plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>${basedir}/src/main/assembly/src.xml</descriptor>
</descriptors>
</configuration> 
<executions>
<execution>
<id>bundle</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>${basedir}/src/main/assembly/src.xml</descriptor>
</descriptors>
</configuration> 
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.googlecode.maven-gcu-plugin</groupId>
<artifactId>maven-gcu-plugin</artifactId>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<uploads>
<upload>
<file>${project.build.directory}/${project.artifactId}-${project.version}-bundle.zip</file>
<summary>MyBatis Generator ${project.version}</summary>
<labels>
<label>Featured</label>
<label>Type-Archive</label>
<label>Product-Generator</label>
<label>Version-${project.version}</label>
</labels>
</upload>
</uploads>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<arguments>-Prelease,gupload</arguments>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
<version>2.0-beta-2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
<scm>
<url>https://mybatis.googlecode.com/svn/sub-projects/generator/tags/mybatis-generator-1.3.2/mybatis-generator-core</url>
<connection>scm:svn:https://mybatis.googlecode.com/svn/sub-projects/generator/tags/mybatis-generator-1.3.2/mybatis-generator-core</connection>
<developerConnection>scm:svn:https://mybatis.googlecode.com/svn/sub-projects/generator/tags/mybatis-generator-1.3.2/mybatis-generator-core</developerConnection>
</scm> 
</project> 

然后是修改src/main/assembly/src.xml代碼

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>bundle</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>src/main/resources</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>generatorConfig.xml</include>
</includes>
<excludes>
<exclude>log4j.properties</exclude>
<exclude>src.xml</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>src/main/scripts</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>run.bat</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>${project.artifactId}-${project.version}.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>${project.artifactId}-${project.version}-sources.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly> 

接下來,在src/main/ 下面新建scripts文件夾,在scripts文件夾新建txt文本文檔,輸入以下代碼

java -jar mybatis-generator-1.3.2.jar -configfile generatorConfig.xml –overwrite
pause

改文件名為run.bat

至此,打包配置完畢。

大家可以在項目下右鍵Run as->maven build 在goal里輸入package?;蛘呙钚衏md中 進入項目的目錄,運行mvn package,這里第一次運行會等待很久,因為maven會下載依賴的jar包,請耐心等待。

打包完畢,就會在項目根目錄下的target目錄生成如下結(jié)構(gòu)

從上圖中我們可以看到mybatis-generator-core-1.3.2.jar包已經(jīng)生成。接下來我們可以用它加上generatorConfig.xml來生成自己想要的代碼。

如果修改代碼過程中有什么不懂的,請多看源代碼。

OK,曬下成果圖

本文就講到這里!

以上所述是小編給大家介紹的Mybatis逆工程jar包的修改和打包的相關(guān)知識,希望對大家有所幫助!

相關(guān)文章

  • Spring Boot如何動態(tài)創(chuàng)建Bean示例代碼

    Spring Boot如何動態(tài)創(chuàng)建Bean示例代碼

    這篇文章主要給大家介紹了關(guān)于Spring Boot如何動態(tài)創(chuàng)建Bean的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-09-09
  • Java的volatile和sychronized底層實現(xiàn)原理解析

    Java的volatile和sychronized底層實現(xiàn)原理解析

    文章詳細介紹了Java中的synchronized和volatile關(guān)鍵字的底層實現(xiàn)原理,包括字節(jié)碼層面、JVM層面的實現(xiàn)細節(jié),以及鎖的類型和MESI協(xié)議在多核處理器中的作用,文章還探討了synchronized和volatile的區(qū)別,以及如何通過Atomic類來實現(xiàn)更細粒度的原子操作,感興趣的朋友一起看看吧
    2025-03-03
  • java 多線程的同步幾種方法

    java 多線程的同步幾種方法

    這篇文章主要介紹了java 多線程的同步幾種方法的相關(guān)資料,這里提供5種方法,需要的朋友可以參考下
    2017-09-09
  • SpringCloud使用CircuitBreaker實現(xiàn)熔斷器的詳細步驟

    SpringCloud使用CircuitBreaker實現(xiàn)熔斷器的詳細步驟

    在微服務(wù)架構(gòu)中,服務(wù)之間的依賴調(diào)用非常頻繁,當一個下游服務(wù)因高負載或故障導(dǎo)致響應(yīng)變慢或不可用時,可能會引發(fā)上游服務(wù)的級聯(lián)故障,最終導(dǎo)致整個系統(tǒng)崩潰,熔斷器是解決這類問題的關(guān)鍵模式之一,Spring Cloud提供了對熔斷器的支持,本文將詳細介紹如何集成和使用它
    2025-02-02
  • SpringBoot中服務(wù)消費的實現(xiàn)

    SpringBoot中服務(wù)消費的實現(xiàn)

    本文主要介紹了SpringBoot中服務(wù)消費的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-07-07
  • Java編程求二叉樹的鏡像兩種方法介紹

    Java編程求二叉樹的鏡像兩種方法介紹

    這篇文章主要介紹了Java編程求二叉樹的鏡像兩種方法介紹,分享了兩種方法,遞歸與非遞歸,每種方法又分別介紹了兩種解決思路,具有一定參考價值,需要的朋友可以了解下。
    2017-11-11
  • SpringBoot項目啟動時如何讀取配置以及初始化資源

    SpringBoot項目啟動時如何讀取配置以及初始化資源

    這篇文章主要給大家介紹了關(guān)于SpringBoot項目啟動時如何讀取配置以及初始化資源的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者使用SpringBoot具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-06-06
  • Spring Boot中的JdbcTemplate是什么及用法小結(jié)

    Spring Boot中的JdbcTemplate是什么及用法小結(jié)

    Spring Boot中的JdbcTemplate是一個強大的數(shù)據(jù)庫訪問工具,它簡化了數(shù)據(jù)庫操作的過程,在本文中,我們了解了JdbcTemplate的基本概念,并演示了如何在Spring Boot應(yīng)用程序中使用它,感興趣的朋友跟隨小編一起看看吧
    2023-10-10
  • SpringCloud集成Sleuth和Zipkin的思路講解

    SpringCloud集成Sleuth和Zipkin的思路講解

    Zipkin 是 Twitter 的一個開源項目,它基于 Google Dapper 實現(xiàn),它致力于收集服務(wù)的定時數(shù)據(jù),以及解決微服務(wù)架構(gòu)中的延遲問題,包括數(shù)據(jù)的收集、存儲、查找和展現(xiàn),這篇文章主要介紹了SpringCloud集成Sleuth和Zipkin,需要的朋友可以參考下
    2022-11-11
  • java對象list使用stream根據(jù)某一個屬性轉(zhuǎn)換成map的3種方式舉例

    java對象list使用stream根據(jù)某一個屬性轉(zhuǎn)換成map的3種方式舉例

    開發(fā)小伙伴們通常會需要使用到對象和Map互相轉(zhuǎn)換的開發(fā)場景,下面這篇文章主要給大家介紹了關(guān)于java對象list使用stream根據(jù)某一個屬性轉(zhuǎn)換成map的3種方式,需要的朋友可以參考下
    2024-01-01

最新評論

白水县| 益阳市| 兴国县| 浦江县| 锡林郭勒盟| 亚东县| 乐东| 光山县| 金沙县| 赤水市| 静海县| 新化县| 台南县| 静宁县| 大兴区| 鄂尔多斯市| 洛阳市| 江川县| 邛崃市| 察雅县| 古浪县| 玉林市| 如东县| 隆德县| 那坡县| 肃宁县| 永城市| 左权县| 寻乌县| 德昌县| 南雄市| 三原县| 保靖县| 余庆县| 长海县| 崇阳县| 潜山县| 苗栗县| 南平市| 阿鲁科尔沁旗| 运城市|