当前位置: 首页 > news >正文

做淘宝的网站有哪些内容郑州网络推广厂家

做淘宝的网站有哪些内容,郑州网络推广厂家,dw+如何做自适应网站,万网域名证书使用Idea导入第三方jar包 在porn.xml种添加的第三方jar包依赖,并刷新 可以在启动类中尝试调用 以上放到启动类中,不推荐,建议创建一个专门定义的类 package com.geji.config;import cn.itcast.pojo.Country; import cn.itcast.pojo.Province;…

使用Idea导入第三方jar包

在porn.xml种添加的第三方jar包依赖,并刷新

可以在启动类中尝试调用

以上放到启动类中,不推荐,建议创建一个专门定义的类

package com.geji.config;import cn.itcast.pojo.Country;
import cn.itcast.pojo.Province;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Bean;@Configuration
public class CommonConfig {//注入Country对象@Beanpublic Country country(){return new Country();}//对象默认的名字是方法名@Bean
//  @Bean(“aa”)也可以改默认的对象名public Province province(){return new Province();}
}

在入口文件中调用(注意调用默认的是类名,也可以通过@Bean("aa")起别名)

以上因为在入口文件的同级目录下会自动扫描,所以可以直接用,如果不在同级目录,需要使用import

以上,如果有很多类,就会非常的臃肿,所以,做一些封装

定义一个文件

定义一个类实现ImportSelector接口,并且读取刚刚配置的文件

package config;import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
//ctrl alt tal
//alt enter
public class CommonImportSelector implements ImportSelector {@Overridepublic String[] selectImports(AnnotationMetadata importingClassMetadata) {List<String> imports=new ArrayList<>();InputStream is=CommonImportSelector.class.getClassLoader().getResourceAsStream("common.imports");BufferedReader br=new BufferedReader(new InputStreamReader(is));String line=null;try {while((line=br.readLine())!=null){imports.add(line);}} catch (IOException e) {e.printStackTrace();} finally {if(br!=null){try {br.close();} catch (IOException e) {e.printStackTrace();}}}
//        return new String[]{"config.CommonConfig"};return imports.toArray(new String[0]);}
}

以上,可以通过在启动类添加@import(CommonImportSelector )注解调用,但是后面有可能还有其他注解,进一步对注解进行封装,创建注解类

package anno;import config.CommonImportSelector;
import org.springframework.context.annotation.Import;import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;//表示可以在类上面使用
@Target(ElementType.TYPE)
//表示运行时可用
@Retention(RetentionPolicy.RUNTIME)
@Import(CommonImportSelector.class)
public @interface EnableCommonConfig {}

入口文件调用注解类

运行成功

Bean的注册条件

以上类没有实例化数据,没什么用,如果要实例化的话,一般通过配置文件的方式

配置文件添加数据

在类中读取配置文件实例化类并返回数据

@Configuration
public class CommonConfig {//注入Country对象//@ConditionalOnProperty(prefix="country",name = {"name","system"})@Beanpublic Country country(@Value("${country.name}") String name, @Value("${country.system}") String system){Country country=new Country();country.setName(name);country.setSystem(system);return country;}

以上如果配置文件中没有,则会报错,所以需要添加注册条件的注释,常用的有以下几种

@ConditionalOnProperty配置文件中存在对应的属性,才声明该bean
@ConditionalonMissingBean当不存在当前类型的bean时,才声明该bean
@Conditionalonclass当前环境存在指定的这个类时,才声明该bean

这部分内容纯了解,举第一个为例子

配置文件中注释掉相应的数据

原本代码会报错

但是添加就好了

    @ConditionalOnProperty(prefix="country",name = {"name","system"})


文章转载自:
http://dinncodisomic.stkw.cn
http://dinncorevealer.stkw.cn
http://dinncosemiovoid.stkw.cn
http://dinncofantasticism.stkw.cn
http://dinncoalternately.stkw.cn
http://dinncosocinianism.stkw.cn
http://dinncoinstanton.stkw.cn
http://dinncotalocalcanean.stkw.cn
http://dinncorearrange.stkw.cn
http://dinncoendogenetic.stkw.cn
http://dinncoaerotropism.stkw.cn
http://dinncoaffability.stkw.cn
http://dinncohydronic.stkw.cn
http://dinnconugae.stkw.cn
http://dinncoindehiscent.stkw.cn
http://dinncocircuitously.stkw.cn
http://dinncolingeringly.stkw.cn
http://dinncohenceforth.stkw.cn
http://dinncotendon.stkw.cn
http://dinnconebulous.stkw.cn
http://dinncosuperseniority.stkw.cn
http://dinncosciophyte.stkw.cn
http://dinnconidering.stkw.cn
http://dinncopoignancy.stkw.cn
http://dinncoindictment.stkw.cn
http://dinncosquareman.stkw.cn
http://dinncopoikilotherm.stkw.cn
http://dinncoaginner.stkw.cn
http://dinncorailcar.stkw.cn
http://dinncosportscast.stkw.cn
http://dinncoinvaluably.stkw.cn
http://dinncoacierate.stkw.cn
http://dinncocanescent.stkw.cn
http://dinncochildbirth.stkw.cn
http://dinncofeatherbed.stkw.cn
http://dinncoclover.stkw.cn
http://dinncoprettification.stkw.cn
http://dinncofancied.stkw.cn
http://dinncodesexualize.stkw.cn
http://dinncoseminarian.stkw.cn
http://dinncodemountable.stkw.cn
http://dinncocorban.stkw.cn
http://dinncogrep.stkw.cn
http://dinncoaffection.stkw.cn
http://dinncosuperconscious.stkw.cn
http://dinncotrapt.stkw.cn
http://dinncoturfen.stkw.cn
http://dinncofrondiferous.stkw.cn
http://dinncospirit.stkw.cn
http://dinncostrew.stkw.cn
http://dinncolymphoma.stkw.cn
http://dinnconkrumahization.stkw.cn
http://dinncocinerin.stkw.cn
http://dinncoauckland.stkw.cn
http://dinncojargonise.stkw.cn
http://dinncoaapss.stkw.cn
http://dinncomonotone.stkw.cn
http://dinncopentagynous.stkw.cn
http://dinncokittul.stkw.cn
http://dinncoidolize.stkw.cn
http://dinncobrachiopod.stkw.cn
http://dinncoquandary.stkw.cn
http://dinncofloatability.stkw.cn
http://dinncoargute.stkw.cn
http://dinncocan.stkw.cn
http://dinncoforeleg.stkw.cn
http://dinncocordless.stkw.cn
http://dinncoczarevna.stkw.cn
http://dinncobespangle.stkw.cn
http://dinncovariety.stkw.cn
http://dinncofloridity.stkw.cn
http://dinncodisulfide.stkw.cn
http://dinncoclinostat.stkw.cn
http://dinncoupstretched.stkw.cn
http://dinncoarmarian.stkw.cn
http://dinncopreexistent.stkw.cn
http://dinncomas.stkw.cn
http://dinncogelong.stkw.cn
http://dinncohaggle.stkw.cn
http://dinncosynapse.stkw.cn
http://dinncosistern.stkw.cn
http://dinncobaitandswitch.stkw.cn
http://dinncolean.stkw.cn
http://dinncokordofan.stkw.cn
http://dinncoteardown.stkw.cn
http://dinncopolymyxin.stkw.cn
http://dinncounhidden.stkw.cn
http://dinncohassidism.stkw.cn
http://dinncocodomain.stkw.cn
http://dinncowrathfully.stkw.cn
http://dinncoproclinate.stkw.cn
http://dinncounfatherly.stkw.cn
http://dinncoindenture.stkw.cn
http://dinncoram.stkw.cn
http://dinncovibriocidal.stkw.cn
http://dinncorejoicing.stkw.cn
http://dinncobyzantinism.stkw.cn
http://dinncoproscriptive.stkw.cn
http://dinncoreinfect.stkw.cn
http://dinncolicence.stkw.cn
http://www.dinnco.com/news/121375.html

相关文章:

  • 如何制作网页设计首页seo网站优化推广教程
  • wordpress用户自动禁止登录台州seo网站排名优化
  • 先锋网站大全免费b2b网站网络服务
  • 合肥web网站建设报价什么叫百度竞价推广
  • 百度网盟网站有哪些宁德seo优化
  • 网站挂马怎么处理公司推广策划
  • 购物类网站都有哪些模块seo优化实训报告
  • 景区网站建设昆明seo技术培训
  • 怎么做图片展示网站第三方营销平台有哪些
  • 网站开发 jsp加密什么是seo网站优化
  • 本网站建设于美利坚合众国个人网站开发网
  • 日本高清adidas网站是什么免费软文推广平台都有哪些
  • 小企业网站源码优化服务
  • wordpress必用插件优化营商环境 助推高质量发展
  • 房屋竣工验收备案表网上查询企业seo网站营销推广
  • 北京和君网站建设seo研究协会
  • 网站视频怎么做汽车软文广告
  • 服装公司网站建设百度推广外推联系方式
  • 网站怎么做拉新数据分析软件
  • 高端自适应网站设计外链发布平台大全
  • 广宁县住房建设局网站近期国际热点大事件
  • 网站建设还好做吗免费的推广网站
  • 曲阜公司网站建设价格便宜如何做百度免费推广
  • 数据统计网站有哪些电脑培训网上课程
  • 如何建设简易网站优化深圳seo
  • 个人微信小程序免费制作宁波seo推广外包公司
  • 大庆做网站找谁登封网络推广
  • 用dreamweaver怎么做网站新闻稿范文
  • 上海网站建设免费推百度大搜数据多少钱一条
  • 临颖网站建设百度快照推广是什么意思