会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132847个问题

老师请问我遍历Value内容的时候打印出来的结果和老师不一样是为什么?

代码:

package com.bjsxt.hashmap;
import java.util.Collection;
import java.util.HashMap;
import java.util.Set;
/**
 * 测试hashMap
 * @author Administrator
 *
 */
public class TestHashMap {
 public  static void  main(String[] args){
  //Map接口的特点,key不允许重复,值可以重复,而且key是无序的
  //创建集合对象
  HashMap hm=new HashMap();
  //(1)添加元素
  hm.put("hello", 123);//123自动装箱成Integer类,集合不允许出现基本数据类型
  hm.put("world", 456);
  hm.put("hello", 1000);//集合去添加元素的时候它的键(key)是不允许重复的,如果重复将进行键的覆盖
  hm.put("java", 1000);//值可以重复(1000)
  
  System.out.println("集合中元素的个数:"+hm.size());
  System.out.println("集合是否为空:"+hm.isEmpty());
  System.out.println(hm);
  System.out.println(hm.remove("world"));//先输出后移除,只移除了键world,456还在
  System.out.println(hm);
  //判断
  //containsKey判断这个键是否存在
  System.out.println(hm.containsKey("java")+"\t"+hm.containsKey("world"));
  //containsValue判断这个值是否存在
  System.out.println(hm.containsValue(1000)+"\t"+hm.containsValue(2000));
  
  //获取元素,根据键去获取值
  System.out.println(hm.get("java")+"\t"+hm.get("world"));
  
  //获取所有键(key)的集合
  Set set=hm.keySet();
  //遍历所有键的内容
  for(Object obj:set){
   System.out.println(obj);
  }
  //获取所有值(value)的集合
  System.out.println("\n---------------------- ");
  Collection coll=hm.values();
  //遍历所有值的类型
  for(Object obj:coll){
   System.out.println(coll);
  }
  //获取所有key-value关系的集合
  Set entrySet=hm.entrySet();
  for(Object obj:entrySet){
   System.out.println(obj);
  }
  
  /**
   * HashMap与Hashtable
   * 区别:
   * (1)版本不同 HashMap JDK1.2  Hashtable JDK1.0
   * (2)HashMap继续了AbstractMap,实现了Map接口,Hashtable继承了Dictionary实现Map接口
   * (3)HashMap允许null值和null键,但是null作为key只允许以一个,Hashtable非null的键和值
   * (4)HashMap是线程不同步的(效率高,安全性低),Hashtable是线程同步的(效率低,安全性高)
   */
  
 }
}

1574938071(1).jpg

JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 6302楼

微信图片_20240625165803.png


Python 全系列/第一阶段:Python入门/Python入门(动画版) 6304楼
Python 全系列/第八阶段:轻量级Web开发利器-Flask框架/Flask高级 6305楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/网络编程(旧) 6308楼
JAVA 全系列/第一阶段:JAVA 快速入门/变量、数据类型、运算符 6309楼
Python 全系列/ 第十三阶段:自动化操作办公软件、邮件、定时任务等/自动化操作办公软件、邮件、定时任务等 6310楼

为什么我启动tomcat7:run错误一大堆

image.png

1.我的zookeeper集群注册中心搭起来了,私服也搭起来了发布是成功的

2.所有代码是老师的源码,因为我自己写一样的效果

全部内容如下:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building ego-manager-web 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> tomcat7-maven-plugin:2.2:run (default-cli) > process-classes @ ego-manager-web >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ ego-manager-web ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ ego-manager-web ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to D:\workspace\ego-manager-web\target\classes
[INFO] 
[INFO] <<< tomcat7-maven-plugin:2.2:run (default-cli) < process-classes @ ego-manager-web <<<
[INFO] 
[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ ego-manager-web ---
[INFO] Running war on http://localhost:8080/
[INFO] Using existing Tomcat server configuration at D:\workspace\ego-manager-web\target\tomcat
[INFO] create webapp with contextPath: 
三月 24, 2020 12:17:11 上午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8080"]
三月 24, 2020 12:17:11 上午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Tomcat
三月 24, 2020 12:17:11 上午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.47
三月 24, 2020 12:17:13 上午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
三月 24, 2020 12:17:13 上午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
三月 24, 2020 12:17:14 上午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'managerItemServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bjsxt.ego.rpc.service.ItemService com.bjsxt.ego.manager.service.impl.ManagerItemServiceImpl.itemServiceProxy; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemServiceProxy': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.bjsxt.ego.rpc.service.ItemService. No provider available for the service com.bjsxt.ego.rpc.service.ItemService from the url zookeeper://192.168.21.133:2181/com.alibaba.dubbo.registry.RegistryService?application=ego-manager-web-consumer&dubbo=2.5.3&interface=com.bjsxt.ego.rpc.service.ItemService&methods=selectItemList&pid=12176&revision=0.0.1-SNAPSHOT&side=consumer&timestamp=1584980234049 to the consumer 192.168.21.1 use dubbo version 2.5.3
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bjsxt.ego.rpc.service.ItemService com.bjsxt.ego.manager.service.impl.ManagerItemServiceImpl.itemServiceProxy; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemServiceProxy': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.bjsxt.ego.rpc.service.ItemService. No provider available for the service com.bjsxt.ego.rpc.service.ItemService from the url zookeeper://192.168.21.133:2181/com.alibaba.dubbo.registry.RegistryService?application=ego-manager-web-consumer&dubbo=2.5.3&interface=com.bjsxt.ego.rpc.service.ItemService&methods=selectItemList&pid=12176&revision=0.0.1-SNAPSHOT&side=consumer&timestamp=1584980234049 to the consumer 192.168.21.1 use dubbo version 2.5.3
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:558)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
	... 22 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemServiceProxy': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.bjsxt.ego.rpc.service.ItemService. No provider available for the service com.bjsxt.ego.rpc.service.ItemService from the url zookeeper://192.168.21.133:2181/com.alibaba.dubbo.registry.RegistryService?application=ego-manager-web-consumer&dubbo=2.5.3&interface=com.bjsxt.ego.rpc.service.ItemService&methods=selectItemList&pid=12176&revision=0.0.1-SNAPSHOT&side=consumer&timestamp=1584980234049 to the consumer 192.168.21.1 use dubbo version 2.5.3
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1506)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:250)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1127)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1051)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:949)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:530)
	... 24 more
Caused by: java.lang.IllegalStateException: Failed to check the status of the service com.bjsxt.ego.rpc.service.ItemService. No provider available for the service com.bjsxt.ego.rpc.service.ItemService from the url zookeeper://192.168.21.133:2181/com.alibaba.dubbo.registry.RegistryService?application=ego-manager-web-consumer&dubbo=2.5.3&interface=com.bjsxt.ego.rpc.service.ItemService&methods=selectItemList&pid=12176&revision=0.0.1-SNAPSHOT&side=consumer&timestamp=1584980234049 to the consumer 192.168.21.1 use dubbo version 2.5.3
	at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:420)
	at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)
	at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138)
	at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:65)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
	... 32 more

三月 24, 2020 12:17:14 上午 org.apache.catalina.core.StandardContext startInternal
严重: Error listenerStart
三月 24, 2020 12:17:14 上午 org.apache.catalina.core.StandardContext startInternal
严重: Context [] startup failed due to previous errors
三月 24, 2020 12:17:14 上午 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
三月 24, 2020 12:17:14 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [DubboRegistryFailedRetryTimer-thread-1] but has failed to stop it. This is very likely to create a memory leak.
三月 24, 2020 12:17:14 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [ZkClient-EventThread-18-192.168.21.133:2181,192.168.21.133:2182,192.168.21.133:2183] but has failed to stop it. This is very likely to create a memory leak.
三月 24, 2020 12:17:14 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [localhost-startStop-1-SendThread(192.168.21.133:2182)] but has failed to stop it. This is very likely to create a memory leak.
三月 24, 2020 12:17:14 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [localhost-startStop-1-EventThread] but has failed to stop it. This is very likely to create a memory leak.
三月 24, 2020 12:17:14 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [DubboSaveRegistryCache-thread-1] but has failed to stop it. This is very likely to create a memory leak.
三月 24, 2020 12:17:14 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]

自己水平实在有限,难以解决都是一步一步跟着走的!

一般错误都能百度出来这个我百度了看不太懂!

JAVA 全系列/(旧的隐藏)第八阶段:电商高级项目_架构/编码/电商ego-基于SOA架构_Dubbo使用_逆向工程_分页插件完成商品查询 6311楼
Python 全系列/第二十八阶段:Hadoop 分布式文件系统:HDFS(扩展)/Hadoop 高可用集群及java API 6313楼
JAVA 全系列/(旧的隐藏)第七阶段:JAVA 高级技术/Linux 6314楼
Python 全系列/第十三阶段:高并发性能怪兽-Tornado 框架/Tornado 数据库操作(旧) 6315楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637