小编bit*_*e77的帖子

Java Lambda风格

所以,这不起作用,因为seatAvailable是最终的.如何使用更多lambda风格的方式完成我想要完成的工作?

final boolean seatsAvailable = false;
theatreSeats.forEach(seat -> {
    if (!seatsAvailable) seatsAvailable = seat.isEmpty();
});
Run Code Online (Sandbox Code Playgroud)

java lambda java-8

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

spring-boot-maven-plugin打破了兄弟模块依赖

我有一个多模块maven设置.一个父模块,加上两个子模块(子),A和B.模块B依赖于A.但是,如果我在模块A中使用spring-boot-maven-plugin,则编译依赖关系无法解析,模块B的编译目标将抛出'找不到符号'和'包不存在'错误.如果我不使用该插件,一切正常,但是我无法在此项目中删除它.

这是一种重现问题的方法:

父pom.xml

<modelVersion>4.0.0</modelVersion>
<groupId>com.whatever</groupId>
<artifactId>theparent</artifactId>
<version>2.7.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
    <module>service</module>
    <module>serviceClient</module>
</modules>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
</parent>
Run Code Online (Sandbox Code Playgroud)

模块A.

<modelVersion>4.0.0</modelVersion>
<artifactId>service</artifactId>
<packaging>jar</packaging>
<parent>
    <groupId>com.whatever</groupId>
    <artifactId>theparent</artifactId>
    <version>2.7.0-SNAPSHOT</version>
    <relativePath>../</relativePath>
</parent>
Run Code Online (Sandbox Code Playgroud)

模块B.

<modelVersion>4.0.0</modelVersion>
<artifactId>serviceClient</artifactId>
<parent>
    <groupId>com.whatever</groupId>
    <artifactId>theparent</artifactId>
    <version>2.7.0-SNAPSHOT</version>
    <relativePath>../</relativePath>
</parent>
<dependencies>
    <dependency>
        <groupId>com.whatever</groupId>
        <artifactId>service</artifactId>
        <version>2.7.0-SNAPSHOT</version>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

现在,您所要做的就是在模块A中有一个类,在模块B中有另一个类,它导入并使用第一个类.它应该编译好,这样做是通过在父模块级别运行'mvn clean install'.但是,在模块A中添加此插件后:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <mainClass>com.whatever.Application</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

,模块B无法再解析模块A的依赖关系,您将看到"包不存在","找不到符号"等消息,表明它无法从模块A中看到该类.

这是一个错误吗?任何人都可以帮我解决这个问题吗?

spring maven spring-boot

2
推荐指数
1
解决办法
2657
查看次数

标签 统计

java ×1

java-8 ×1

lambda ×1

maven ×1

spring ×1

spring-boot ×1