小编Yan*_*Rui的帖子

stream和parallelStream

我有一个像这样的测试代码:

List<Integer> list = new ArrayList<>(1000000);

for(int i=0;i<1000000;i++){
    list.add(i);
}

List<String> values = new ArrayList<>(1000000);

list.stream().forEach(
    i->values.add(new Date().toString())
);

System.out.println(values.size()); 
Run Code Online (Sandbox Code Playgroud)

运行这个,我得到了一个正确的输出:1000000.

但是,如果我将其更改stream()parallelStream(),则:

 list.parallelStream().forEach(
    i->values.add(new Date().toString())
 );
Run Code Online (Sandbox Code Playgroud)

我有一个随机输出,例如:920821.

怎么了?

java java-stream

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

@ConfigurationPropertiesspectj-maven-plugin冲突

当我@ConfigurationProperties在基于aspectj-maven-plugin的maven编译过程中使用时,我收到以下错误消息:

[信息] 显示类型消息的 AJC 消息详细信息:[错误、警告、失败] [警告] 不支持 @ConfigurationProperty 元数据的字段值处理:

[错误]内部编译器错误:java.lang.IllegalStateException:无法在 org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.writeMetaData(ConfigurationMetadataAnnotationProcessor.java:367) 写入元数据

这是我的 pom 设置:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
     <artifactId>aspectj-maven-plugin</artifactId>
     <version>1.8</version>
     <configuration>
         <forceAjcCompile>true</forceAjcCompile>
         <source>${java.version}</source>
         <target>${java.version}</target>
         <Xlint>ignore</Xlint>
         <complianceLevel>${java.version   </complianceLevel>
         <showWeaveInfo>true</showWeaveInfo>
         <encoding>${project.build.sourceEncoding}</encoding>
         <verbose>true</verbose>
         <!--<aspectLibraries/>-->
     </configuration>
     <executions>
         <execution>
             <goals>
                <goal>compile</goal>
                <goal>test-compile</goal>
             </goals>
         </execution>
     </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

解决办法是什么?

java spring maven spring-boot

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

如何读取角度组件中的所有@input成员?

我需要使用 @Input() 装饰器读取角度组件中的所有属性。我尝试了reflect和reflect-metadata,但都失败了,如何实现这个功能?

decorator angular

0
推荐指数
1
解决办法
1110
查看次数

标签 统计

java ×2

angular ×1

decorator ×1

java-stream ×1

maven ×1

spring ×1

spring-boot ×1