spring-boot注解詳解(七)

@Configuration

從Spring3.0,@Configuration用于定義配置類,可替換xml配置文件,被注解的類內部包含有一個或多個被@Bean注解的方法,這些方法將會被AnnotationConfigApplicationContext或AnnotationConfigWebApplicationContext類進行掃描,并用于構建bean定義,初始化Spring容器。

注意:@Configuration注解的配置類有如下要求:

@Configuration不可以是final類型;
@Configuration不可以是匿名類;
嵌套的configuration必須是靜態類。
一、用@Configuration加載spring
1.1、@Configuration配置spring并啟動spring容器
1.2、@Configuration啟動容器+@Bean注冊Bean
1.3、@Configuration啟動容器+@Component注冊Bean
1.4、使用 AnnotationConfigApplicationContext 注冊 AppContext 類的兩種方法
1.5、配置Web應用程序(web.xml中配置AnnotationConfigApplicationContext)

二、組合多個配置類
2.1、在@configuration中引入spring的xml配置文件
2.2、在@configuration中引入其它注解配置
2.3、@configuration嵌套(嵌套的Configuration必須是靜態類)
三、@EnableXXX注解
四、@Profile邏輯組配置
五、使用外部變量
一、@Configuation加載Spring方法
1.1、@Configuration配置spring并啟動spring容器
@Configuration標注在類上,相當于把該類作為spring的xml配置文件中的,作用為:配置spring容器(應用上下文)

package com.dxz.demo.configuration;import org.springframework.context.annotation.Configuration;@Configuration
public class TestConfiguration {public TestConfiguration() {System.out.println("TestConfiguration容器啟動初始化。。。");}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"  xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:util="http://www.springframework.org/schema/util" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsdhttp://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsdhttp://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd" default-lazy-init="false"></beans>
package com.dxz.demo.configuration;import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;public class TestMain {public static void main(String[] args) {// @Configuration注解的spring容器加載方式,用AnnotationConfigApplicationContext替換ClassPathXmlApplicationContextApplicationContext context = new AnnotationConfigApplicationContext(TestConfiguration.class);// 如果加載spring-context.xml文件:// ApplicationContext context = new// ClassPathXmlApplicationContext("spring-context.xml");}
}

在這里插入圖片描述
1.2、@Configuration啟動容器+@Bean注冊Bean,@Bean下管理bean的生命周期
@Bean標注在方法上(返回某個實例的方法),等價于spring的xml配置文件中的,作用為:注冊bean對象

bean類:

package com.dxz.demo.configuration;public class TestBean {private String username;private String url;private String password;public void sayHello() {System.out.println("TestBean sayHello...");}public String toString() {return "username:" + this.username + ",url:" + this.url + ",password:" + this.password;}public void start() {System.out.println("TestBean 初始化。。。");}public void cleanUp() {System.out.println("TestBean 銷毀。。。");}
}
package com.dxz.demo.configuration;import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;@Configuration
public class TestConfiguration {public TestConfiguration() {System.out.println("TestConfiguration容器啟動初始化。。。");}// @Bean注解注冊bean,同時可以指定初始化和銷毀方法// @Bean(name="testBean",initMethod="start",destroyMethod="cleanUp")@Bean@Scope("prototype")public TestBean testBean() {return new TestBean();}
}
package com.dxz.demo.configuration;import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;public class TestMain {public static void main(String[] args) {// @Configuration注解的spring容器加載方式,用AnnotationConfigApplicationContext替換ClassPathXmlApplicationContextApplicationContext context = new AnnotationConfigApplicationContext(TestConfiguration.class);// 如果加載spring-context.xml文件:// ApplicationContext context = new// ClassPathXmlApplicationContext("spring-context.xml");//獲取beanTestBean tb = (TestBean) context.getBean("testBean");tb.sayHello();}
}

在這里插入圖片描述
注:
(1)、@Bean注解在返回實例的方法上,如果未通過@Bean指定bean的名稱,則默認與標注的方法名相同;
(2)、@Bean注解默認作用域為單例singleton作用域,可通過@Scope(“prototype”)設置為原型作用域;
(3)、既然@Bean的作用是注冊bean對象,那么完全可以使用@Component、@Controller、@Service、@Ripository等注解注冊bean,當然需要配置@ComponentScan注解進行自動掃描。
@Bean下管理bean的生命周期
可以使用基于 Java 的配置來管理 bean 的生命周期。@Bean 支持兩種屬性,即 initMethod 和destroyMethod,這些屬性可用于定義生命周期方法。在實例化 bean 或即將銷毀它時,容器便可調用生命周期方法。生命周期方法也稱為回調方法,因為它將由容器調用。使用 @Bean 注釋注冊的 bean 也支持 JSR-250 規定的標準 @PostConstruct 和 @PreDestroy 注釋。如果您正在使用 XML 方法來定義 bean,那么就應該使用 bean 元素來定義生命周期回調方法。以下代碼顯示了在 XML 配置中通常使用 bean 元素定義回調的方法。

@Configuration
@ComponentScan(basePackages = "com.dxz.demo.configuration")
public class TestConfiguration {public TestConfiguration() {System.out.println("TestConfiguration容器啟動初始化。。。");}//@Bean注解注冊bean,同時可以指定初始化和銷毀方法@Bean(name="testBean",initMethod="start",destroyMethod="cleanUp")@Scope("prototype")public TestBean testBean() {return new TestBean();}
}
public class TestMain {public static void main(String[] args) {ApplicationContext context = new AnnotationConfigApplicationContext(TestConfiguration.class);TestBean tb = (TestBean) context.getBean("testBean");tb.sayHello();System.out.println(tb);TestBean tb2 = (TestBean) context.getBean("testBean");tb2.sayHello();System.out.println(tb2);}
}

在這里插入圖片描述
分析:

結果中的1:表明initMethod生效

結果中的2:表明@Scope(“prototype”)生效
1.3、@Configuration啟動容器+@Component注冊Bean
bean類:

package com.dxz.demo.configuration;import org.springframework.stereotype.Component;//添加注冊bean的注解
@Component
public class TestBean {private String username;private String url;private String password;public void sayHello() {System.out.println("TestBean sayHello...");}public String toString() {return "username:" + this.username + ",url:" + this.url + ",password:" + this.password;}public void start() {System.out.println("TestBean 初始化。。。");}public void cleanUp() {System.out.println("TestBean 銷毀。。。");}
}
package com.dxz.demo.configuration;import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;@Configuration
//添加自動掃描注解,basePackages為TestBean包路徑
@ComponentScan(basePackages = "com.dxz.demo.configuration")
public class TestConfiguration {public TestConfiguration() {System.out.println("TestConfiguration容器啟動初始化。。。");}/*// @Bean注解注冊bean,同時可以指定初始化和銷毀方法// @Bean(name="testNean",initMethod="start",destroyMethod="cleanUp")@Bean@Scope("prototype")public TestBean testBean() {return new TestBean();}*/
}
package com.dxz.demo.configuration;import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;public class TestMain {public static void main(String[] args) {// @Configuration注解的spring容器加載方式,用AnnotationConfigApplicationContext替換ClassPathXmlApplicationContextApplicationContext context = new AnnotationConfigApplicationContext(TestConfiguration.class);// 如果加載spring-context.xml文件:// ApplicationContext context = new// ClassPathXmlApplicationContext("spring-context.xml");//獲取beanTestBean tb = (TestBean) context.getBean("testBean");tb.sayHello();}
}

sayHello()方法都被正常調用。
在這里插入圖片描述
1.4、使用 AnnotationConfigApplicationContext 注冊 AppContext 類的兩種方法
1.4.1、 配置類的注冊方式是將其傳遞給 AnnotationConfigApplicationContext 構造函數

public static void main(String[] args) {// @Configuration注解的spring容器加載方式,用AnnotationConfigApplicationContext替換ClassPathXmlApplicationContextApplicationContext context = new AnnotationConfigApplicationContext(TestConfiguration.class);//獲取beanTestBean tb = (TestBean) context.getBean("testBean");tb.sayHello();}

1.4.2、 AnnotationConfigApplicationContext 的register 方法傳入配置類來注冊配置類

public static void main(String[] args) {ApplicationContext ctx = new AnnotationConfigApplicationContext();ctx.register(AppContext.class)
}

1.5、配置Web應用程序(web.xml中配置AnnotationConfigApplicationContext)
過去,您通常要利用 XmlWebApplicationContext 上下文來配置 Spring Web 應用程序,即在 Web 部署描述符文件 web.xml 中指定外部 XML 上下文文件的路徑。XMLWebApplicationContext 是 Web 應用程序使用的默認上下文類。以下代碼描述了 web.xml 中指向將由 ContextLoaderListener 監聽器類載入的外部 XML 上下文文件的元素。

<web-app><context-param><param-name>contextConfigLocation</param-name><param-value>/WEB-INF/applicationContext.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><servlet><servlet-name>sampleServlet</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class></servlet>...
</web-app>

現在,您要將 web.xml 中的上述代碼更改為使用 AnnotationConfigApplicationContext 類。切記,XmlWebApplicationContext 是 Spring 為 Web 應用程序使用的默認上下文實現,因此您永遠不必在您的web.xml 文件中顯式指定這個上下文類。現在,您將使用基于 Java 的配置,因此在配置 Web 應用程序時,需要在web.xml 文件中指定 AnnotationConfigApplicationContext 類。上述代碼將修改如下:

<web-app><context-param><param-name>contextClass</param-name><param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value></context-param><context-param><param-name>contextConfigLocation</param-name><param-value>demo.AppContext</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><servlet><servlet-name>sampleServlet</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextClass</param-name><param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value></init-param></servlet>...
</web-app>

以上修改后的 web.xml 現在定義了 AnnotationConfigWebApplicationContext 上下文類,并將其作為上下文參數和 servlet 元素的一部分。上下文配置位置現在指向 AppContext 配置類。這非常簡單。下一節將演示 bean 的生命周期回調和范圍的實現。

1.6、@Configuation總結
@Configuation等價于

@Bean等價于

@ComponentScan等價于<context:component-scan base-package=“com.dxz.demo”/>

二、組合多個配置類

2.1、在@configuration中引入spring的xml配置文件

package com.dxz.demo.configuration2;import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;@Configuration
@ImportResource("classpath:applicationContext-configuration.xml")
public class WebConfig {
}
package com.dxz.demo.configuration2;public class TestBean2 {private String username;private String url;private String password;public void sayHello() {System.out.println("TestBean2 sayHello...");}public String toString() {return "TestBean2 username:" + this.username + ",url:" + this.url + ",password:" + this.password;}public void start() {System.out.println("TestBean2 初始化。。。");}public void cleanUp() {System.out.println("TestBean2 銷毀。。。");}
}
package com.dxz.demo.configuration2;import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;public class TestMain2 {public static void main(String[] args) {// @Configuration注解的spring容器加載方式,用AnnotationConfigApplicationContext替換ClassPathXmlApplicationContextApplicationContext context = new AnnotationConfigApplicationContext(WebConfig.class);// 如果加載spring-context.xml文件:// ApplicationContext context = new// ClassPathXmlApplicationContext("spring-context.xml");// 獲取beanTestBean2 tb = (TestBean2) context.getBean("testBean2");tb.sayHello();}
}

在這里插入圖片描述
2.2、在@configuration中引入其它注解配置

package com.dxz.demo.configuration2;import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;import com.dxz.demo.configuration.TestConfiguration;@Configuration
@ImportResource("classpath:applicationContext-configuration.xml")
@Import(TestConfiguration.class)
public class WebConfig {
}
package com.dxz.demo.configuration2;import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;import com.dxz.demo.configuration.TestBean;public class TestMain2 {public static void main(String[] args) {// @Configuration注解的spring容器加載方式,用AnnotationConfigApplicationContext替換ClassPathXmlApplicationContextApplicationContext context = new AnnotationConfigApplicationContext(WebConfig.class);// 如果加載spring-context.xml文件:// ApplicationContext context = new// ClassPathXmlApplicationContext("spring-context.xml");// 獲取beanTestBean2 tb2 = (TestBean2) context.getBean("testBean2");tb2.sayHello();TestBean tb = (TestBean) context.getBean("testBean");tb.sayHello();}
}

在這里插入圖片描述
2.3、@configuration嵌套(嵌套的Configuration必須是靜態類)
通過配置類嵌套的配置類,達到組合多個配置類的目的。但注意內部類必須是靜態類。

上代碼:

package com.dxz.demo.configuration3;import org.springframework.stereotype.Component;@Component
public class TestBean {private String username;private String url;private String password;public void sayHello() {System.out.println("TestBean sayHello...");}public String toString() {return "username:" + this.username + ",url:" + this.url + ",password:" + this.password;}public void start() {System.out.println("TestBean start");}public void cleanUp() {System.out.println("TestBean destory");}
}
package com.dxz.demo.configuration3;public class DataSource {private String dbUser;private String dbPass;public String getDbUser() {return dbUser;}public void setDbUser(String dbUser) {this.dbUser = dbUser;}public String getDbPass() {return dbPass;}public void setDbPass(String dbPass) {this.dbPass = dbPass;}@Overridepublic String toString() {return "DataSource [dbUser=" + dbUser + ", dbPass=" + dbPass + "]";}
}
package com.dxz.demo.configuration3;import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;@Configuration
@ComponentScan(basePackages = "com.dxz.demo.configuration3")
public class TestConfiguration {public TestConfiguration() {System.out.println("TestConfiguration容器啟動初始化。。。");}@Configurationstatic class DatabaseConfig {@BeanDataSource dataSource() {return new DataSource();}}
}
package com.dxz.demo.configuration3;import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;public class TestMain {public static void main(String[] args) {// @Configuration注解的spring容器加載方式,用AnnotationConfigApplicationContext替換ClassPathXmlApplicationContextsApplicationContext context = new AnnotationConfigApplicationContext(TestConfiguration.class);//beanTestBean tb = (TestBean) context.getBean("testBean");tb.sayHello();DataSource ds = (DataSource) context.getBean("dataSource");System.out.println(ds);}
}

在這里插入圖片描述
3、@EnableXXX注解
配合@Configuration使用,包括 @EnableAsync, @EnableScheduling, @EnableTransactionManagement, @EnableAspectJAutoProxy, @EnableWebMvc。

@EnableAspectJAutoProxy—《spring AOP 之:@Aspect注解》

@EnableScheduling–《Spring 3.1新特性之二:@Enable*注解的源碼,spring源碼分析之定時任務Scheduled注解》

4、@Profile邏輯組配置
見《Spring的@PropertySource + Environment,@PropertySource(PropertySourcesPlaceholderConfigurer)+@Value配合使用》

5、使用外部變量
1、@PropertySource + Environment,通過@PropertySource注解將properties配置文件中的值存儲到Spring的 Environment中,Environment接口提供方法去讀取配置文件中的值,參數是properties文件中定義的key值。
2、@PropertySource(PropertySourcesPlaceholderConfigurer)+@Value

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/250143.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/250143.shtml
英文地址,請注明出處:http://en.pswp.cn/news/250143.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

[pytorch、學習] - 5.2 填充和步幅

參考 5.2 填充和步幅 5.2.1 填充 填充(padding)是指在輸入高和寬的兩側填充元素(通常是0元素)。圖5.2里我們在原輸入高和寬的兩側分別添加了值為0的元素,使得輸入高和寬從3變成了5,并導致輸出高和寬由2增加到4。圖5.2中的陰影部分為第一個輸出元素及其計算所使用的輸入和核數…

java實現Comparable接口和Comparator接口,并重寫compareTo方法和compare方法

原文地址https://segmentfault.com/a/1190000005738975 實體類:java.lang.Comparable(接口) comareTo(重寫方法)&#xff0c;業務排序類 java.util.Comparator(接口) compare(重寫方法). 這兩個接口我們非常的熟悉&#xff0c;但是 在用的時候會有一些不知道怎么下手的感覺&a…

hdu 4714 樹+DFS

題目鏈接&#xff1a;http://acm.hdu.edu.cn/showproblem.php?pid4714 本來想直接求樹的直徑&#xff0c;再得出答案&#xff0c;后來發現是錯的。 思路&#xff1a;任選一個點進行DFS&#xff0c;對于一棵以點u為根節點的子樹來說&#xff0c;如果它的分支數大于1&#xff0c…

springboot----shiro集成

springboot中集成shiro相對簡單&#xff0c;只需要兩個類&#xff1a;一個是shiroConfig類&#xff0c;一個是CustonRealm類。 ShiroConfig類&#xff1a; 顧名思義就是對shiro的一些配置&#xff0c;相對于之前的xml配置。包括&#xff1a;過濾的文件和權限&#xff0c;密碼加…

[pytorch、學習] - 5.3 多輸入通道和多輸出通道

參考 5.3 多輸入通道和多輸出通道 前面兩節里我們用到的輸入和輸出都是二維數組,但真實數據的維度經常更高。例如,彩色圖像在高和寬2個維度外還有RGB(紅、綠、藍)3個顏色通道。假設彩色圖像的高和寬分別是h和w(像素),那么它可以表示為一個3 * h * w的多維數組。我們將大小為3…

非阻塞算法簡介

在不只一個線程訪問一個互斥的變量時&#xff0c;所有線程都必須使用同步&#xff0c;否則就可能會發生一些非常糟糕的事情。Java 語言中主要的同步手段就是 synchronized 關鍵字&#xff08;也稱為內在鎖&#xff09;&#xff0c;它強制實行互斥&#xff0c;確保執行 synchron…

springboot---成員初始化順序

如果我們的類有如下成員變量&#xff1a; Component public class A {Autowiredpublic B b; // B is a beanpublic static C c; // C is also a beanpublic static int count;public float version;public A() {System.out.println("This is A constructor.");}Au…

[pytorch、學習] - 5.4 池化層

參考 5.4 池化層 在本節中我們介紹池化(pooling)層,它的提出是為了緩解卷積層對位置的過度敏感性。 5.4.1 二維最大池化層和平均池化層 池化層直接計算池化窗口內元素的最大值或者平均值。該運算也叫做最大池化層或平均池化層。 下面把池化層的前向計算實現在pool2d函數里…

mac上安裝Chromedriver注意事宜

mac上安裝Chromedriver注意事宜&#xff1a; 1.網上下載chromedriver文件或在百度網盤找chromedirver文件 2.將 chromedriver 放置到&#xff1a;/usr/local/bin/&#xff0c;操作如下&#xff1a; 打開Mac終端terminal : 進入 chromedirve文件所在目錄&#xff0c;輸入命令: s…

freemarker教程

FreeMarker的模板文件并不比HTML頁面復雜多少,FreeMarker模板文件主要由如下4個部分組成: 1.文本:直接輸出的部分 2.注釋:<#-- … -->格式部分,不會輸出 3.插值:即${…}或#{…}格式的部分,將使用數據模型中的部分替代輸出 4.FTL指令:FreeMarker指定,和HTML標記類似,名字前…

[pytorch、學習] - 5.5 卷積神經網絡(LeNet)

參考 5.5 卷積神經網絡&#xff08;LeNet&#xff09; 卷積層嘗試解決兩個問題: 卷積層保留輸入形狀,使圖像的像素在高和寬兩個方向上的相關性均可能被有效識別;卷積層通過滑動窗口將同一卷積核和不同位置的輸入重復計算,從而避免參數尺寸過大。 5.5.1 LeNet模型 LeNet分為…

Android內存管理機制

好文摘錄 原作&#xff1a; https://www.cnblogs.com/nathan909/p/5372981.html 1、基于Linux內存管理 Android系統是基于Linux 2.6內核開發的開源操作系統&#xff0c;而linux系統的內存管理有其獨特的動態存儲管理機制。不過Android系統對Linux的內存管理機制進行了優化&…

【Ruby】Ruby 類案例

閱讀目錄 Ruby類案例保存并執行代碼Ruby類案例 下面將創建一個名為 Customer 的 Ruby 類&#xff0c;聲明兩個方法&#xff1a; display_details&#xff1a;該方法用于顯示客戶的詳細信息。total_no_of_customers&#xff1a;該方法用于顯示在系統中創建的客戶總數量。實例 #!…

[pytorch、學習] - 5.6 深度卷積神經網絡(AlexNet)

參考 5.6 深度卷積神經網絡&#xff08;AlexNet&#xff09; 在LeNet提出后的將近20年里,神經網絡一度被其他機器學習方法超越,如支持向量機。雖然LeNet可以在早期的小數據集上取得好的成績,但是在更大的真實數據集上的表現并不盡如人意。一方面,神經網絡計算復雜。雖然20世紀…

Springboot---Model,ModelMap,ModelAndView

Model&#xff08;org.springframework.ui.Model&#xff09; Model是一個接口&#xff0c;包含addAttribute方法&#xff0c;其實現類是ExtendedModelMap。 ExtendedModelMap繼承了ModelMap類&#xff0c;ModelMap類實現了Map接口。 public class ExtendedModelMap extends M…

東南亞支付——柬埔寨行

考察時間&#xff1a;2018.5.28 至 2018.6.6 為了解柬埔寨大概國情和市場&#xff0c;在柬埔寨開展了為期近10天的工作。 觀察了交通情況&#xff0c;周邊街道的店面與商品&#xff0c;攤販等&#xff0c;也走訪了大學校區&#xff0c;看了永旺商超、本地超市和中國超市&#x…

Puzzle (II) UVA - 519

題目鏈接&#xff1a; https://vjudge.net/problem/UVA-519 思路&#xff1a; 剪枝回溯 這個題巧妙的是他按照表格的位置開始搜索&#xff0c;也就是說表格是定的&#xff0c;他不斷用已有的圖片從(0,0)開始拼到(n-1,m-1) 剪枝的地方&#xff1a; 1.由于含F的面只能拼到邊上&am…

[pytorch、學習] - 5.7 使用重復元素的網絡(VGG)

參考 5.7 使用重復元素的網絡&#xff08;VGG&#xff09; AlexNet在LeNet的基礎上增加了3個卷積層。但AlexNet作者對它們的卷積窗口、輸出通道數和構造順序均做了大量的調整。雖然AlexNet指明了深度卷積神經網絡可以取得出色的結果&#xff0c;但并沒有提供簡單的規則以指導…

springboot---mybits整合

配置 POM文件 <parent> <groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.5.6.RELEASE</version><relativePath /> </parent><properties><proj…

使用airdrop進行文件共享

使用airdrop進行文件共享 學習了&#xff1a; https://support.apple.com/zh-cn/HT203106 https://zh.wikihow.com/%E5%9C%A8Mac%E4%B8%8A%E7%94%A8%E8%BF%91%E6%9C%BA%E6%8D%B7%E4%BC%A0%EF%BC%88Airdrop%EF%BC%89%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6 轉載于:https://www.cn…