小编Sha*_*thi的帖子

春天有应用范围吗?

我在下面的博客中看到了"应用程序"范围.这是真的吗?

http://www.concretepage.com/spring/spring-bean-scope-example-using-scope-annotation-and-xml-for-singleton-prototype-request-session-global-session-and-application-scope-与范围的代理

因为,根据我的冲浪,我知道spring只有5个以下的范围.如果我错了,请纠正我.

  1. 独生子
  2. 原型
  3. 请求
  4. 会议
  5. 全球会议

java spring spring-mvc application-scope

8
推荐指数
1
解决办法
1万
查看次数

Java 8拆分字符串并在Map内部创建Map

我有一个像这样的字符串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)

java split java-8 java-stream

7
推荐指数
1
解决办法
481
查看次数

在Spring项目中集成Spring Boot

我有一个使用弹簧靴创建的现有战争项目.如何在具有EJB模块的EAR中打包它?

有没有办法将模型和dao包移动到EJB模块并使用WAR模块注入它?

ear spring spring-boot

6
推荐指数
2
解决办法
8321
查看次数

如何从Hibernate Entity到DTO深层复制内部对象?

我有实体课

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单独使用.如何复制addressprofile也?

如果必须编写custom util,请分享一下代码段吗?

java apache-commons-beanutils spring-bean

5
推荐指数
1
解决办法
711
查看次数

Spring Boot Rest Service 是否需要“生产”和“消费”属性?

我正在使用 Spring Boot 开发 REST 服务。如果我使用响应实体,我的模型对象默认会生成 JSON。

在这种情况下,我是否需要在每个服务中指定consumes和属性?produces

rest spring spring-boot

5
推荐指数
1
解决办法
3227
查看次数

带有数据 JPA 不工作的 Spring Boot 多模块

我有我的多模块 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)

multi-module spring-data-jpa spring-boot

4
推荐指数
1
解决办法
4353
查看次数