【java – 带有动态键和值的Spring bean映射】教程文章相关的互联网学习教程文章

java-要映射的地图流【代码】

如何在Java 8中将Map(相同类型)的Stream扁平化为单个Map?Map<String, Long> toMap(Stream<Map<String, Long>> stream) {return stream. ??? }解决方法:我的语法可能有点差,但是flatMap应该为您完成大部分工作:Map<String, Long> toMap(Stream<Map<String, Long>> stream) {return stream.flatMap (map -> map.entrySet().stream()) // this would create a flattened// Stream of all the map entries.collect(Collectors.toMap(...

如何在Java 8中映射值?【代码】

这个问题已经在这里有了答案: > Using streams, how can I map the values in a HashMap? 3个说我有一个Map< String,Integer>.是否有一种简单的方法来获取Map< String,String>从中? 简单来说,我的意思不是这样:Map<String, String> mapped = new HashMap<>(); for(String key : originalMap.keySet()) {mapped.put(key, originalMap.get(key).toString()); }但是有些...

添加库项目时将android R.java映射到资源布局【代码】

我在android R.java behavior when a library project is added 我观察到,将库项目添加到任何android项目时,都会创建两个R.java文件. project.R.javapublic static final class layout {public static int capture=0x7f030000;public static int main=0x7f030001; }lib.R.javapublic static final class layout {public static final int add=0x7f030000;public static final int capture=0x7f030001;public static final int main...

友好的网址映射问题-Java Spring【代码】

我在web.xml上的所有页面都都显示为404的错误中挣扎,可能存在根路径,但是我不确定其设置位置等. 这是我当前的web.xml<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/java...

java-如何在不映射根xml元素的情况下解组xml?【代码】

我想解组一个包含数据集合的xml文件,像这样<Persons><Person>Jim</Person><Person>Tom</Person> </Persons>我们知道这可以通过两个类完成:人员,使用Castor的人员,JAXB或其他框架. 但是,不编写收集类Persons怎么办?解决方法:寻找一种方法告诉Castor您希望它生成Person实例的java.util.List. http://www.castor.org/how-to-map-a-list-at-root.html

java-映射超类上的命名查询【代码】

我正在尝试在映射的超类上声明NamedQuery,但出现此错误:org.hibernate.hql.ast.QuerySyntaxException: VoipCall is not mapped [select v from VoipCall v where v.audioFile = :audioFile]我们使用休眠模式,但是我们更喜欢使用JPA标准符号. 这是代码:@MappedSuperclass @NamedQueries(value = {@NamedQuery(name = "getVoipCallsForAudio", query = "select v from VoipCall v where v.audioFile = :audioFile") }) public abst...

java-如何使用映射器将自定义查询字符串附加到grails资源?【代码】

我想创建一个Grails资源映射器,将查询字符串附加到actualUrl.到目前为止,所有尝试都失败了-但也许我会以错误的方式进行尝试.示例代码如下;import org.grails.plugin.resource.mapper.MapperPhase import org.apache.commons.logging.LogFactoryclass GlobalizationResourceMapper {def log = LogFactory.getLog(this.class)def phase = MapperPhase.RENAMINGdef operation = "globalizationquerystring"def priority = -1static d...

Java大文件上传引发java.io.IOException:映射失败【代码】

我正在使用Spring和Hibernate并尝试上传大文件,但是当我尝试上传时超过150 Mb,则产生错误,例如Caused by: java.lang.OutOfMemoryError: Map failed at sun.nio.ch.FileChannelImpl.map0(Native Method) at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:755) ... 157 more我正在使用Windows 64位操作系统.经过大量的谷歌搜索后,我发现这是JDK中可用的错误.谁能帮我解决这个问题? 有人写过这个问题https://github.com/MLCL...

java-避免在Spring MVC请求映射中使用URI中的浮点数来检测文件扩展名【代码】

我使用Spring Boot来实现REST应用程序.我有一个这样映射的资源@RequestMapping(value = "/{fromLat}/{fromLon}/{toLat}/{toLon:.+}", method = {RequestMethod.GET},produces = {"application/json"})因此,路径包含坐标,并且请求如下所示$curl -I -X GET http://localhost:8085/foobar/53.481297/9.900539/53.491691/9.946046不幸的是,最后一端被解释为文件扩展名,该文件扩展名导致响应头提供文件下载,而不仅仅是原始数据.Content-...

java – 检查映射中的所有值是否相等【代码】

我需要检查地图中的所有值是否相等.我有一个方法来执行此任务,但想使用库或本机方法.限制:Java 5 Apache Commons库.public static boolean isUnique(Map<Dboid,?> aMap){boolean isUnique = true; Object currValue = null; int iteration = 0;Iterator<?> it = aMap.entrySet().iterator();while(it.hasNext() && isUnique){iteration++;Object value = it.next();if(iteration > 1){if (value != null && currValue == null ||v...

java – 你可以收集(join())而不映射到字符串吗?【代码】

我正在阅读java 8,并且作者说如果你有一个覆盖toString方法的类,那么在进行collect(joined())时你不需要将流映射到字符串.一个例子:public static void main(String... args) {List<Person> people =Arrays.asList(new Person(23, "Paul"),new Person(23, "John"),new Person(23, "Greg"),new Person(24, "Greg"),new Person(25, "Paul")); // Person overrides toStringString peopleString = people.stream().collect(Collector...

使用JAXB映射包含超类型和子类型的Java集合【代码】

我正在尝试用JAXB生成这样的东西:<person><firstName>Foo</firstName><lastName>Bar</lastName><identities><green id="greenId"><some_elements....</green><blue id="blueId"/></identities>< identity>的子元素一切都源于一个普通的超级阶级. 在Java中它是这样的:@XmlRootElement(name = "person") public class Person {public String firstName; public String lastName;@XmlElementWrapper(name = "identities")public Set...

映射到Java 8中的运行总和【代码】

如果我有一个集合:List<Long> numbers = asList(2, 2, 4, 5);如何映射/处理这些以构建运行总计.生产类似的东西:List<Long> runningTotals = asList(2, 4, 8, 13);更好的是,我如何建立一个列表(如元组),以便我可以保留orignals:((2 -> 2), (2 -> 4), (4 -> 8), (5 -> 13));解决方法:更新:正如Holger在评论中指出的,使用Stream.reduce()为此目的是不正确的.有关更多信息,请参见Reduction和Mutable Reduction或Java 8 Streams – ...

java – 引起:org.hibernate.MappingException:实体映射中的重复列【代码】

我是初学者用maven和JBOSS处理JPA,用Restful来制作我的应用程序我有以下问题我做了DEPLOYCaused by: javax.persistence.PersistenceException: [PersistenceUnit: com.company.test_resources_war_1.0-SNAPSHOTPU] Unable to build EntityManagerFactoryCaused by: org.hibernate.MappingException: Repeated column in mapping for entity: database.Photo column: fid_module (should be mapped with insert = \ "false \" updat...

java – 如何将Spring Boot @RepositoryRestResource映射到特定的URL?【代码】

我似乎无法在以下任何位置映射我的存储库:@RepositoryRestResource(collectionResourceRel = "item", path = "item") public interface ItemRepository extends PagingAndSortingRepository<Item, Long> {我以为我可以用:path = "/some/other/path/item"但映射无法解决.我明白了:HTTP ERROR 404Problem accessing /some/other/path/item. Reason:Not Found在spring-data中,javadoc路径定义为:“The path segment under which t...

映射 - 相关标签