我在下面的博客中看到了"应用程序"范围.这是真的吗?
因为,根据我的冲浪,我知道spring只有5个以下的范围.如果我错了,请纠正我.
我有一个像这样的字符串101-1-5,101-2-4,102-1-5,102-2-5,102-3-5,103-1-4。
我想将此添加到中Map<String, Map<String, String>>。
喜欢: {101={1=5, 2=4}, 102={1=5, 2=5, 3=5}, 103={1=4}}
如何使用Java 8流执行此操作?
我尝试使用普通的Java。而且效果很好。
public class Util {
public static void main(String[] args) {
String samp = "101-1-5,101-2-4,102-1-5,102-2-5,102-3-5,103-1-4";
Map<String, Map<String, String>> m1 = new HashMap<>();
Map<String, String> m2 = null;
String[] items = samp.split(",");
for(int i=0; i<items.length; i++) {
String[] subitem = items[i].split("-");
if(!m1.containsKey(subitem[0]) || m2==null) {
m2 = new HashMap<>();
}
m2.put(subitem[1], subitem[2]);
m1.put(subitem[0], m2);
}
System.out.println(m1);
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个使用弹簧靴创建的现有战争项目.如何在具有EJB模块的EAR中打包它?
有没有办法将模型和dao包移动到EJB模块并使用WAR模块注入它?
我有实体课
public Class StudentEntity{
private int id;
private String name;
private AddressEntity address;
private ProfileEntity profile;
//getter setter
}
public Class StudentDTO{
private int id;
private String name;
private AddressDTO address;
private ProfileDTO profile;
//getter setter
}
Run Code Online (Sandbox Code Playgroud)
当我使用BeanUtils.copyProperties();(从spring/apache常见)它复制id并且name单独使用.如何复制address和profile也?
如果必须编写custom util,请分享一下代码段吗?
我正在使用 Spring Boot 开发 REST 服务。如果我使用响应实体,我的模型对象默认会生成 JSON。
在这种情况下,我是否需要在每个服务中指定consumes和属性?produces
我有我的多模块 Spring Boot 项目。我将服务、实体和存储库移至核心模块,而在 war 模块中,我只有控制器。
这里有什么问题?如果我在没有 JPA 的情况下使用,那么我的核心模块工作正常。如果我在核心模块中添加 JPA 依赖项并在我的服务中注入存储库,那么我会收到各种错误,例如存储库的 noclassdefinitionfound、没有服务类型的合格 bean 等。
如何使这个应用程序工作?
父 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<name>appx</name>
<modelVersion>4.0.0</modelVersion>
<groupId>org.imsx</groupId>
<artifactId>appx</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>core</module>
<module>webx</module>
<module>imsx</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<version.wildfly.maven.plugin>1.0.2.Final</version.wildfly.maven.plugin>
<version.jboss.bom>8.2.1.Final</version.jboss.bom>
<version.wildfly>14.0.1.Final</version.wildfly>
<version.compiler.plugin>3.8.0</version.compiler.plugin>
<version.ear.plugin>3.0.1</version.ear.plugin>
<version.jar.plugin>3.1.1</version.jar.plugin>
<version.war.plugin>3.2.2</version.war.plugin>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
<version>${version.compiler.plugin}</version>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
<inherited>true</inherited>
<configuration>
<skip>true</skip> …Run Code Online (Sandbox Code Playgroud) java ×3
spring ×3
spring-boot ×3
ear ×1
java-8 ×1
java-stream ×1
multi-module ×1
rest ×1
split ×1
spring-bean ×1
spring-mvc ×1