小编Fus*_*sel的帖子

Java Map computeIfAbsent问题

所以我发现了Java的Map computeIfAbsent(使用java8)方法的好奇心,我希望有人能告诉我为什么会发生这种情况,因为我无法真正遵循该问题背后的逻辑.

所以,我有一个带有键的Map(显然),值是一个列表,当没有设置键时,我使用computeIfAbsent创建一个新列表.现在,当我使用Integer作为键时,我可以使用以下内容:

List<Object> list = map.computeIfAbsent(1, ArrayList::new);
Run Code Online (Sandbox Code Playgroud)

但是当我使用String作为密钥尝试使用时

List<Object> list = map.computeIfAbsent("key", ArrayList::new);
Run Code Online (Sandbox Code Playgroud)

我得到了错误The method computeIfAbsent(String, Function<? super String,? extends List<Object>>) in the type Map<String,List<Object>> is not applicable for the arguments (String, ArrayList::new).是否缺少实施?使用String键我必须使用类似的方法,然后再次使用.

List<Object> list = map.computeIfAbsent("key", k -> new ArrayList<>());
Run Code Online (Sandbox Code Playgroud)

也许有人可以启发我.谢谢 :)

java functional-programming java-8

13
推荐指数
2
解决办法
738
查看次数

PHP 启动:无法在 Ubuntu 中加载动态库“openssl”

我收到问题标题中的错误消息,或者确切地说我收到了这条消息

  PHP Startup: Unable to load dynamic library 'openssl'
  (tried: /usr/lib/php/20170718/openssl (/usr/lib/php/20170718/openssl: 
  cannot open shared object file: No such file or directory), 
  /usr/lib/php/20170718/openssl.so (/usr/lib/php/20170718/openssl.so: cannot 
  open shared object file: No such file or directory)) in Unknown
Run Code Online (Sandbox Code Playgroud)

我真正的问题是它只是有时而不是总是发生。在一秒钟内,请求有效,而在另一秒钟内,我在同一请求中收到此消息的 500 内部错误。

这在我启用 apacheproxyproxy_wstunnelmods后开始发生,但也可能是一个apt-get upgradeapt-get update.

来自phpinfo();

  • 版本:PHP 版本 7.2.4-1+ubuntu16.04.1+deb.sury.org+1
  • 已启用 OpenSSL 支持
  • OpenSSL 库版本 OpenSSL 1.1.0h 2018 年 3 月 27 日
  • OpenSSL 标头版本 OpenSSL 1.1.0h 2018 年 3 月 27 日 …

php ubuntu openssl

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

Tomcat部署旧版本的Webapp

这可能是重复的,因为我无法想象我们是第一个遇到这种情况的人,但是我似乎找不到它。

因此,我们正在使用Maven使用gitlab ci将WAR文件部署到tomcat 8.5服务器。问题是当我们从0.2.9升级到0.2.10时,tomcat弄乱了版本。显然,服务器按字母顺序部署了WAR,并且0.2.10位于0.2.1和0.2.2之间,并且即使0.2.10已正确部署到服务器,运行版本仍为0.2.9。

完整的Web应用程序名称类似于:WebappName ## 0.2.10-SNAPSHOT_201901010000.war

我们曾考虑过将版本重命名为0.2.009和0.2.010,但这似乎是一个很肮脏的解决方法。当然,较旧的版本会不时地被删除,因此这不是一个永久性的问题,但这有点令人讨厌,有关如何解决此问题的任何提示都很棒。

从pom.xml

<version>0.2.10-SNAPSHOT</version>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.install.skip>true</maven.install.skip>
    <timestamp>${maven.build.timestamp}</timestamp>
    <maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
</properties>
[..]
<profile>
    <id>deploy-stage</id>
    <activation>
        <activeByDefault>false</activeByDefault>
    </activation>
    <properties>
        <war.name>WebappName##${project.version}_${timestamp}</war.name>
        <tomcat.url>http://[..]/manager/text</tomcat.url>
        <tomcat.server>[..]</tomcat.server>
        <tomcat.webpath>/${war.name}</tomcat.webpath>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <id>default-war</id>
                        <goals>
                            <goal>manifest</goal>
                            <goal>war</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
                <configuration>
                        <warName>${war.name}</warName>
                    <failOnMissingWebXml>true</failOnMissingWebXml>
                    <archive>
                        <addMavenDescriptor>true</addMavenDescriptor>
                        <forced>true</forced>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <packageName>true</packageName>
                            <useUniqueVersions>true</useUniqueVersions>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Build-Time>${maven.build.timestamp}</Build-Time>
                            <Archetype>${archetypeArtifactId}</Archetype>
                            <Archetype-Version>${archetypeVersion}</Archetype-Version>
                        </manifestEntries>
                    </archive>
                    <webResources>
                        <resource>
                            <filtering>true</filtering>
                            <directory>src/main/webapp</directory>
                            <includes>
                                <include>**/web.xml</include>
                            </includes>
                        </resource>
                    </webResources>
                    <warSourceDirectory>src/main/webapp</warSourceDirectory>
                    <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration> …
Run Code Online (Sandbox Code Playgroud)

deployment tomcat maven gitlab gitlab-ci

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