草庐IT

collection_names

全部标签

名称[EJB:..]在此上下文中不绑定。无法找到[ejb:]。]有根本原因Javax.Naming.NamenotfoundException in Wildfly

我试图在偏远的环境中致电我的EJB,并将Wildfly用作我的容器。抱歉,这是我第一次试图以远程方式致电EJB。我使用以下说明来调用野生蝇中的EJB。https://docs.jboss.org/author/display/wfly8/ejb+invocations+from+a+remote+client+client+using+jndi但是,我遇到了一个错误,称这些ejbs,我不知道我的配置有什么问题。请参阅下面的错误堆栈跟踪:SEVERE:Servlet.service()forservlet[dispatcher]incontextwithpath[/Project-demo]th

java - Spring 启动(带 jpa 的 mysql): No bean named 'entityManagerFactory' available

开始构建(第一个)springboot应用程序,这是我的springboot主类(Fullcodeongithub)@EnableAutoConfiguration@SpringBootApplicationpublicclassApplication{publicstaticvoidmain(String[]args){SpringApplication.run(Application.class,args);}}这是pom.xml4.0.0com.exampledemo0.0.1-SNAPSHOTjardemoDemoprojectforSpringBootorg.springfr

java - 采访 : Design an iterator for a collection of collections

为java中的集合设计一个迭代器。迭代器应该隐藏嵌套,允许您迭代属于所有集合的所有元素,就好像您在处理单个集合一样 最佳答案 这是一个老问题,但如今(2019年)我们有了JDK8+好东西。特别是,我们有流,这使得这个任务变得简单:publicstaticIteratorflatIterator(Collection>collections){returncollections.stream().filter(Objects::nonNull).flatMap(Collection::stream).iterator();}我正在过滤

java - 使用 Jackson 实现 Collection 的类的反序列化失败

我有以下JSON:{"item":[{"foo":1},{"foo":2}]}这基本上是一个包含项目集合的对象。所以我做了一个类来反序列化:publicclassItemList{@JsonProperty("item")Listitems;//Getters,setters&co.//...}到目前为止一切正常。现在,为了让我在其他地方的生活更轻松,我决定能够迭代ItemList对象并让它实现Collection接口(interface)会很好。所以基本上我的类(class)变成了:publicclassItemListimplementsCollection,Iterable{@J

java - Stream collect with Generic 类型

我尝试在将json反序列化为pojo的方法中使用泛型,以便它可以返回任何对象类型。这是我的代码:privateBla(Listas,Listbs){this.as=as;this.bs=bs;}publicstaticBlafrom(JsonObjectjson){returnnewBla(Bla.load(json,As),Bla.load(json,Bs));}privatestaticListload(JsonObjectjsonObject,Stringparam){returnjsonObject.getJsonArray(param).stream().map(Bla::g

java - 为什么Stream <T> collect方法返回不同的键顺序?

我有以下代码:publicenumContinent{ASIA,EUROPE}publicclassCountry{privateStringname;privateContinentregion;publicCountry(Stringna,Continentreg){this.name=na;this.region=reg;}publicStringgetName(){returnname;}publicContinentgetRegion(){returnregion;}@OverridepublicStringtoString(){return"Country[name="+n

java - 你能以编程方式访问当前的 Heroku dyno id/name 吗?

在Heroku上,您能否以编程方式从应用程序中获取当前正在执行代码的dyno的某种标识符?例如dyno名称(例如“web.1”或“worker.1”)或其他一些ID。如果是,如何在Java中执行此操作? 最佳答案 总是有机器的主机名(看起来像d.LONG_GUID。我想(虽然没有尝试过)这应该有效:Stringlocalhostname=java.net.InetAddress.getLocalHost().getHostName();此外,还有一个鲜为人知的secret,但您可以通过查看环境变量PS1的值来获取“web.1”、“w

Java : programmatically determine all of the package names loaded on the classpath

关于如何找到当前类路径中存在的包名称列表,有什么建议吗?这需要在运行时通过在类路径上加载(和执行)的类之一以编程方式完成(即由内而外,而不是由外而内)。更多详情:我考虑的一种方法是对类加载器到目前为止加载的每个类使用反射,并从中提取包名称。但是,我的应用程序已经运行了数千个类,因此我需要一种更高效的方法。我考虑的另一件事类似于找出类路径中的JAR文件,然后为每个JAR并行列出目录。但是,我不知道这是否可以从应用程序内部实现/如何实现。奖励积分任何建议可以按顶级包过滤的方法的人都可以获得奖励积分。例如。显示com.xyz下的所有包==>com.xyz.*,com.xyz.*.*谢谢!

java - JPA 标准 API : How to select property in nested collection

我有一个类Customer和CustomerDependant实体。Customer与其家属有多对多的双向关系。我需要查找按姓名和相关姓名过滤的客户。它在JPQL中做了类似这样的事情:selectcjoinfetchc.dependantsdfromCustomercwherec.namelike'foo'andd.namelike'foo'我如何使用JPA标准查询做同样的事情? 最佳答案 摘自JPA规范第6.5.4节CriteriaQueryq=cb.createQuery(Department.class);Rootd=q.fr

Java 编译器 : How can two methods with the same name and different signatures match a method call?

我有一个名为Container的类:publicclassContainer{privatefinalMapmap=newHashMap();publicvoidput(Stringname,Objectvalue){map.put(name,value);}publicContainerwith(Stringname,Objectvalue){put(name,value);returnthis;}publicObjectget(Stringname){returnmap.get(name);}publicRget(Stringname,Functionmapper){Objectv