中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

在線觀看視頻網(wǎng)站怎么做活動推廣宣傳方案

在線觀看視頻網(wǎng)站怎么做,活動推廣宣傳方案,做網(wǎng)站還要寫文章嗎,給人做閹割手術(shù)的網(wǎng)站0. 為啥感覺升級了 win11 之后,電腦像是剛買回來的,很快 這篇加餐完全是一個意外:時隔兩年半,再看 Springboot-quartz-starter 集成實現(xiàn)的時候,不知道為啥我的h2 在應(yīng)用啟動的時候,不能自動創(chuàng)建quartz相關(guān)…

0. 為啥感覺升級了 win11 之后,電腦像是剛買回來的,很快

這篇加餐完全是一個意外:時隔兩年半,再看 Springboot-quartz-starter 集成實現(xiàn)的時候,不知道為啥我的h2 在應(yīng)用啟動的時候,不能自動創(chuàng)建quartz相關(guān)的schema。后面看了 springboot 的文檔,據(jù)說是可以做到的,AI也是這么說的。

沒辦法,只能看 QuartzAutoConfiguration 源碼了。于是乎,就有了這么個好活

沒辦法,就當是一個支線任務(wù)了

1. AbstractScriptDatabaseInitializer

請?zhí)砑訄D片描述

下面是熟悉的,閹割后的 源碼

package org.springframework.boot.sql.init;/*** Base class for an {@link InitializingBean} that performs SQL database initialization* using schema (DDL) and data (DML) scripts.** @author Andy Wilkinson* @since 2.5.0*/
public abstract class AbstractScriptDatabaseInitializer implements ResourceLoaderAware, InitializingBean {// 構(gòu)造入?yún)⑴渲?/span>private final DatabaseInitializationSettings settings;private volatile ResourceLoader resourceLoader;@Overridepublic void afterPropertiesSet() throws Exception {// 初始化后,就執(zhí)行邏輯了initializeDatabase();}/*** Initializes the database by applying schema and data scripts.* @return {@code true} if one or more scripts were applied to the database, otherwise* {@code false}*/public boolean initializeDatabase() {ScriptLocationResolver locationResolver = new ScriptLocationResolver(this.resourceLoader);// 先后執(zhí)行 schema, data 的腳本boolean initialized = applySchemaScripts(locationResolver);return applyDataScripts(locationResolver) || initialized;}// 真正執(zhí)行腳本前,會走這個判斷,決定是否要執(zhí)行腳本private boolean isEnabled() {if (this.settings.getMode() == DatabaseInitializationMode.NEVER) {return false;}return this.settings.getMode() == DatabaseInitializationMode.ALWAYS || isEmbeddedDatabase();}/*** Returns whether the database that is to be initialized is embedded.* @return {@code true} if the database is embedded, otherwise {@code false}* @since 2.5.1*/protected boolean isEmbeddedDatabase() {throw new IllegalStateException("Database initialization mode is '" + this.settings.getMode() + "' and database type is unknown");}private boolean applySchemaScripts(ScriptLocationResolver locationResolver) {return applyScripts(this.settings.getSchemaLocations(), "schema", locationResolver);}private boolean applyDataScripts(ScriptLocationResolver locationResolver) {return applyScripts(this.settings.getDataLocations(), "data", locationResolver);}private boolean applyScripts(List<String> locations, String type, ScriptLocationResolver locationResolver) {List<Resource> scripts = getScripts(locations, type, locationResolver);if (!scripts.isEmpty() && isEnabled()) {runScripts(scripts);return true;}return false;}// 根據(jù)配置的 路徑的字符串 -> spring.Resource 類型private List<Resource> getScripts(List<String> locations, String type, ScriptLocationResolver locationResolver) {if (CollectionUtils.isEmpty(locations)) {return Collections.emptyList();}List<Resource> resources = new ArrayList<>();for (String location : locations) {for (Resource resource : doGetResources(location, locationResolver)) {if (resource.exists()) {resources.add(resource);}}}return resources;}private List<Resource> doGetResources(String location, ScriptLocationResolver locationResolver) {return locationResolver.resolve(location);}private void runScripts(List<Resource> resources) {runScripts(resources, this.settings.isContinueOnError(), this.settings.getSeparator(),this.settings.getEncoding());}protected abstract void runScripts(List<Resource> resources, boolean continueOnError, String separator,Charset encoding);private static class ScriptLocationResolver {private final ResourcePatternResolver resourcePatternResolver;private List<Resource> resolve(String location) throws IOException {// ...}}}

再看幾個它的實現(xiàn)類,加載上配置類,基本上,可以知道它的使用方法了

2. 吾のDemo

始于測試類

package org.pajamas.spring.boot;import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.pajamas.example.starter.core.entity.AlbumEntity;
import org.pajamas.example.starter.core.repo.AlbumRepo;
import org.pajamas.example.test.AbstractApplicationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.TestPropertySource;import java.util.List;/*** @author william* @since 2024/5/30*/
@DisplayName("what the interesting component")
@TestPropertySource(properties = {"spring.application.name=service-example-test",// 屏蔽 liquibase 的干擾 "spring.liquibase.enabled=false"
})
@Import(ExampleDatabaseInitializer.class)
public class DatabaseInitializerTest extends AbstractApplicationTest {// 其實就,一個 jpa 實體類的 repository@AutowiredAlbumRepo repo;// @Disabled@DisplayName("execute DDL, DML automatically, as App startup")@Testpublic void t0() throws Exception {// 預(yù)期的結(jié)果:啟動啟動時,自動創(chuàng)建表,并插入一條記錄List<AlbumEntity> all = this.repo.findAll();printErr(all);}
}

既然是測試,就走簡單的方式,注冊這個bean

package org.pajamas.spring.boot;import org.springframework.boot.autoconfigure.sql.init.SqlDataSourceScriptDatabaseInitializer;
import org.springframework.boot.autoconfigure.sql.init.SqlInitializationProperties;
import org.springframework.boot.sql.init.DatabaseInitializationMode;import java.util.Collections;import javax.sql.DataSource;/*** @author william* @since 2024/5/30*/
public class ExampleDatabaseInitializer extends SqlDataSourceScriptDatabaseInitializer {public ExampleDatabaseInitializer(DataSource dataSource) {super(dataSource, getProperty());}private static SqlInitializationProperties getProperty() {SqlInitializationProperties properties = new SqlInitializationProperties();properties.setSchemaLocations(Collections.singletonList("classpath:sql/schema.sql"));properties.setDataLocations(Collections.singletonList("classpath:sql/data.sql"));properties.setMode(DatabaseInitializationMode.ALWAYS);properties.setContinueOnError(false);return properties;}
}

schema.sql

CREATE TABLE IF NOT EXISTS `t_album`
(`id`             bigint NOT NULL AUTO_INCREMENT,`album_name`     varchar(32)                                                  DEFAULT NULL COMMENT 'album name',`album_year`     int                                                          DEFAULT NULL COMMENT 'album publish year',`create_date`    timestamp NULL DEFAULT NULL,`create_user_id` bigint                                                       DEFAULT NULL,`update_date`    timestamp NULL DEFAULT NULL,`update_user_id` bigint                                                       DEFAULT NULL,`ver`            int    NOT NULL                                              DEFAULT '0',`del`            bigint NOT NULL                                              DEFAULT '0',PRIMARY KEY (`id`),UNIQUE KEY `uni_album_id_del` (`id`,`del`)
) COMMENT='album table';CREATE TABLE IF NOT EXISTS `t_artist`
(`id`             bigint NOT NULL AUTO_INCREMENT,`artist_name`    varchar(32)                                                  DEFAULT NULL COMMENT 'artist name',`artist_from`    varchar(32)                                                  DEFAULT NULL COMMENT 'shorten of country name',`create_date`    timestamp NULL DEFAULT NULL,`create_user_id` bigint                                                       DEFAULT NULL,`update_date`    timestamp NULL DEFAULT NULL,`update_user_id` bigint                                                       DEFAULT NULL,`ver`            int    NOT NULL                                              DEFAULT '0',`del`            bigint NOT NULL                                              DEFAULT '0',PRIMARY KEY (`id`),UNIQUE KEY `uni_artist_id_del` (`id`,`del`)
) COMMENT='artist table';

data.sql

insert into`t_album`
(`album_name`,`album_year`,`create_user_id`,`update_user_id`
)
values
('Boomerang',2023,1023,1023
);

3. 話說回來:為甚么,我的h2沒有自動創(chuàng)建quartz的schema

這是springboot.Quartz的實現(xiàn)
在這里插入圖片描述

接下來,源碼啟動…

package org.springframework.boot.jdbc.init;/*** {@link InitializingBean} that performs {@link DataSource} initialization using schema* (DDL) and data (DML) scripts.** @author Andy Wilkinson* @since 2.5.0*/
public class DataSourceScriptDatabaseInitializer extends AbstractScriptDatabaseInitializer {@Overrideprotected boolean isEmbeddedDatabase() {try {// step into ..return EmbeddedDatabaseConnection.isEmbedded(this.dataSource);}catch (Exception ex) {logger.debug("Could not determine if datasource is embedded", ex);return false;}}
}----------// org.springframework.boot.jdbc.EmbeddedDatabaseConnection/*** Convenience method to determine if a given data source represents an embedded* database type.* @param dataSource the data source to interrogate* @return true if the data source is one of the embedded types*/public static boolean isEmbedded(DataSource dataSource) {try {return new JdbcTemplate(dataSource)// step into ....execute(new IsEmbedded());}catch (DataAccessException ex) {// Could not connect, which means it's not embeddedreturn false;}}----------// org.springframework.boot.jdbc.EmbeddedDatabaseConnection.IsEmbedded@Overridepublic Boolean doInConnection(Connection connection) throws SQLException, DataAccessException {DatabaseMetaData metaData = connection.getMetaData();String productName = metaData.getDatabaseProductName();if (productName == null) {return false;}productName = productName.toUpperCase(Locale.ENGLISH);// step into ...EmbeddedDatabaseConnection[] candidates = EmbeddedDatabaseConnection.values();for (EmbeddedDatabaseConnection candidate : candidates) {if (candidate != NONE && productName.contains(candidate.getType().name())) {// 根據(jù)jdbc.url判斷是不是一個 嵌入式數(shù)據(jù)庫String url = metaData.getURL();return (url == null || candidate.isEmbeddedUrl(url));}}return false;}------------public enum EmbeddedDatabaseConnection {// H2 判斷是否為嵌入式數(shù)據(jù)的依據(jù)/*** H2 Database Connection.*/H2(EmbeddedDatabaseType.H2, DatabaseDriver.H2.getDriverClassName(),"jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE", (url) -> url.contains(":h2:mem")),}

破案:我的h2 使用默認的 file(xxx.mv.db) 存儲,默認配置下(DatabaseInitializationMode.EMBEDDED), 只有內(nèi)存(嵌入式)的數(shù)據(jù)庫會開啟這個特性。

  • 要么配置 DatabaseInitializationMode.ALWAYS
  • 要么使用內(nèi)存數(shù)據(jù)庫

Anyway, h2支持好多種連接方式,新版本h2, 默認的file模式,采用mv的storeEngine 支持MVCC。所以說,對于quartz這種依賴行鎖的要求,也是支持的。

4. 話又說回去… 這個東西對項目的意義是什么

  • 可以試下這個:如果你有一個連接數(shù)據(jù)庫的測試環(huán)境,或者你的程序很簡單,又或者 有特殊的xp(內(nèi)存數(shù)據(jù)庫)
  • 專門數(shù)據(jù)庫的版本控制工具:你的程序比較復(fù)雜,或者 本身就需要數(shù)據(jù)庫的版本控制工具(如 Liquibase),運行在嚴肅的生產(chǎn)環(huán)境
http://www.risenshineclean.com/news/50942.html

相關(guān)文章:

  • 一般網(wǎng)站建設(shè)多少錢怎么才能讓百度收錄網(wǎng)站
  • 哪些網(wǎng)站可以做教師資格證題目seo網(wǎng)絡(luò)優(yōu)化軟件
  • 嘉興網(wǎng)站公司哪家好上海seo優(yōu)化培訓(xùn)機構(gòu)
  • 安裝wordpress 500 - 內(nèi)部服務(wù)器錯誤.手機百度seo怎么優(yōu)化
  • 建設(shè)網(wǎng)站要在需求長沙縣網(wǎng)絡(luò)營銷咨詢
  • 前端特效網(wǎng)站cnzz統(tǒng)計
  • photoshop怎么做網(wǎng)站百度網(wǎng)站關(guān)鍵詞排名查詢
  • 龍海市城鄉(xiāng)規(guī)劃建設(shè)局網(wǎng)站優(yōu)化網(wǎng)站內(nèi)容
  • 嘉興制作網(wǎng)站企業(yè)西安seo外包優(yōu)化
  • 贛州做公司網(wǎng)站手機網(wǎng)站智能建站
  • 嘉興企業(yè)網(wǎng)站開發(fā)可以免費發(fā)帖的網(wǎng)站
  • asp.net做的音樂網(wǎng)站杭州最專業(yè)的seo公司
  • 網(wǎng)站自助建設(shè)平臺有哪些廣州競價托管公司
  • 做企業(yè)網(wǎng)站推廣多少錢百度官方網(wǎng)站登錄
  • 做曖曖視頻網(wǎng)站安全嗎百度營銷官網(wǎng)
  • 網(wǎng)站建設(shè)好公司好營銷網(wǎng)站做的好的公司
  • 做問卷哪個網(wǎng)站好愛站網(wǎng)關(guān)鍵詞密度
  • wordpress獲取當前頁面鏈接seo搜索優(yōu)化專員
  • 如何在雅虎臺灣做企業(yè)網(wǎng)站站長工具綜合查詢2020
  • 網(wǎng)站 平臺建設(shè)情況介紹優(yōu)化公司網(wǎng)站排名
  • 電腦網(wǎng)站模板網(wǎng)頁模板免費下載
  • 禪城區(qū)網(wǎng)站建設(shè)公司優(yōu)化網(wǎng)站平臺
  • 可以做軟文的網(wǎng)站營銷策略范文
  • 網(wǎng)站建設(shè)熊貓建站百度如何發(fā)布作品
  • 做網(wǎng)站需要買空間么 服務(wù)器福州百度開戶多少錢
  • 網(wǎng)站代碼在哪看查詢網(wǎng)站收錄
  • 網(wǎng)絡(luò)培訓(xùn)ppt天天seo百度點擊器
  • 在網(wǎng)站上保存網(wǎng)址怎么做國內(nèi)打開google網(wǎng)頁的方法
  • 設(shè)計公司網(wǎng)站建設(shè)方案百度搜索引擎營銷案例
  • wordpress 媒體庫 API抖音seo查詢工具