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

网站插件代码大全/可以推广赚钱的软件

网站插件代码大全,可以推广赚钱的软件,本地江苏网站建设,珠海网站制作推广公司哪家好文章目录一、搭建环境二、使用Set方式注入1、实现依赖注入2、测试一、搭建环境 打开IDEA创建不使用骨架的Maven工程&#xff0c;然后打开pim.xml&#xff0c;导入SpringFreamwork与Junit&#xff1a; <dependencies><!-- https://mvnrepository.com/artifact/junit/…

文章目录

  • 一、搭建环境
  • 二、使用Set方式注入
    • 1、实现依赖注入
    • 2、测试


一、搭建环境

打开IDEA创建不使用骨架的Maven工程,然后打开pim.xml,导入SpringFreamworkJunit

<dependencies><!-- https://mvnrepository.com/artifact/junit/junit --><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency><!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc --><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>5.2.12.RELEASE</version></dependency>
</dependencies>

创建一个包含所有类型的实体类:

创建Address实体类,作为另一个实体类的属性用:

package com.wzq.pojo;public class Address {private String address;public String getAddress() {return address;}public void setAddress(String address) {this.address = address;}@Overridepublic String toString() {return "Address{" +"address='" + address + '\'' +'}';}
}

创建Student类:

package com.wzq.pojo;import java.util.*;public class Student {//属性:private String name;private Address address;private String[] books;private List<String> hobbys;private Map<String,String> card;private Set<String> games;private String wife;    //这个用来注入空,毕竟没有媳妇儿private Properties info;public String getName() {return name;}public void setName(String name) {this.name = name;}public Address getAddress() {return address;}public void setAddress(Address address) {this.address = address;}public String[] getBooks() {return books;}public void setBooks(String[] books) {this.books = books;}public List<String> getHobbys() {return hobbys;}public void setHobbys(List<String> hobbys) {this.hobbys = hobbys;}public Map<String, String> getCard() {return card;}public void setCard(Map<String, String> card) {this.card = card;}public Set<String> getGames() {return games;}public void setGames(Set<String> games) {this.games = games;}public String getWife() {return wife;}public void setWife(String wife) {this.wife = wife;}public Properties getInfo() {return info;}public void setInfo(Properties info) {this.info = info;}@Overridepublic String toString() {return "Student{" +"name='" + name + '\'' +", address=" + address +", books=" + Arrays.toString(books) +", hobbys=" + hobbys +", card=" + card +", games=" + games +", wife='" + wife + '\'' +", info=" + info +'}';}
}

创建beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttps://www.springframework.org/schema/beans/spring-beans.xsd"><bean id="address" class="com.wzq.pojo.Address"><property name="address" value="洛阳"/></bean>
</beans>

二、使用Set方式注入

1、实现依赖注入

打开beans.xml(说明都在注释里):

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttps://www.springframework.org/schema/beans/spring-beans.xsd"><bean id="address" class="com.wzq.pojo.Address"><property name="address" value="洛阳"/></bean><bean id="student" class="com.wzq.pojo.Student"><!-- 默认方式 --><property name="name" value="wzq"/><!-- 对象 --><property name="address" ref="address"/><!-- 数组 --><property name="books"><array><value>红楼梦</value><value>西游记</value><value>水浒传</value><value>三国演义</value></array></property><!-- list --><property name="hobbys"><list><value>听歌</value><value>敲代码</value><value>看电影</value></list></property><!-- Map --><property name="card"><map><entry key="身份证" value="41032xxxxxxxxxxxxx"/><entry key="银行卡" value="41032xxxxxxxxxxxxx"/></map></property><!-- Set --><property name="games"><set><value>英雄联盟</value><value>王者荣耀</value><value>吃鸡</value></set></property><!-- null --><property name="wife"><null/></property><!-- properties --><property name="info"><props><prop key="driver">driver</prop><prop key="url">url</prop><prop key="username">username</prop><prop key="password">password</prop></props></property></bean></beans>

2、测试

使用Junti测试:

import com.wzq.pojo.Student;
import com.wzq.pojo.User;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class MyTest {@Testpublic void Test(){ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");Student student = context.getBean("student", Student.class);System.out.println(student.toString());}
}

输出结果:

Student{name='wzq',address=Address{address='洛阳'},books=[红楼梦, 西游记, 水浒传, 三国演义],hobbys=[听歌, 敲代码, 看电影],card={身份证=41032xxxxxxxxxxxxx, 银行卡=41032xxxxxxxxxxxxx},games=[英雄联盟, 王者荣耀, 吃鸡],wife='null',info={password=password, url=url, driver=driver, username=username}
}
http://www.lbrq.cn/news/1473157.html

相关文章:

  • 制作免费制作个人网站怎么做/西地那非片能延时多久每次吃多少
  • 做便民工具网站怎么样/seo优化文章网站
  • 青岛建立网站电话/宣传渠道有哪些
  • wap社区游戏入口/网站优化的意义
  • 做企业云网站的企业邮箱/seo搜索优化专员招聘
  • 产品网站开发计划表/百度推广怎么操作流程
  • 网站建设是属于b2/google付费推广
  • 中山建设局网站首页/怎么在百度免费推广
  • 深圳网站制作开发/上海广告推广
  • 怎么做网站底部版权信息/企业qq邮箱
  • 给别人做的网站要复杂做安全扫描/营销推广48个方法
  • 有没有做软件的外包网站/滁州网站seo
  • 怎么做营销网站/怎么seo关键词优化排名
  • 建设商务网站的经济可行性分析/市场营销四大基本策略
  • 制作网站网站/广州推广seo
  • 天津企业网站策划公司/适合网络营销的产品
  • 类似建E网模型网站建设/湖南网站seo推广
  • 哪家网站做推广好/百度获客平台
  • 自助下单网站怎么做/女教师遭网课入侵直播
  • 企业门户网站开发要多少钱/东莞优化排名公司
  • 专业做简历的网站/seo网站系统
  • 宜昌市住房和城乡建设官方网站/微信小程序开发教程
  • 建设网站有哪些/优化推广网站排名
  • 南通网站建设推广专家/网站建设推广公司
  • 个人网站起个名字/厦门站长优化工具
  • 网站建设的前期准备/谷歌浏览器下载安卓版
  • 腹黑的网站骚动做图动态网站/网络营销师官网
  • 常见的网站开发工具有哪些/百度怎么找人工客服
  • 做网站北京/百度账号出售平台
  • app开发价格一览表/seo免费课程视频
  • Python 环境配置
  • SpringMVC核心原理与实战指南
  • 类与对象(上),咕咕咕
  • Spark的宽窄依赖
  • 问题1:uniapp在pages样式穿刺没有问题,在components组件中样式穿刺小程序不起效果
  • 【swoole Windows 开发(swoole-cli 开发 hyperf)】