小编Unk*_*own的帖子

Eclipse每次运行项目时修改server.xml(运行 - >在服务器上运行)

我在Eclipse Juno上使用Tomcat 7.我使用工作区元数据作为服务器位置(请参阅下面的我的tomcat配置).

Tomcat配置

另外,我在eclipse中获得了一个服务器项目 [请参见下图],其中包含单独的server.xml和其他配置文件.

服务器项目

通常它工作正常.在我更改了SSL配置的server.xml(在eclipse项目中)后,问题出现了.

配置工作正常.但每次运行项目(运行 - >运行在服务器上)时,server.xml都会被修改为默认版本.我的自定义SSL更改缺失.

此外,我尝试在tomcat安装位置(C:\ apache-tomcat-7.0.35\conf)中更改server.xml,但它没有从eclipse中选择.

有人可以帮我这个吗?

谢谢

eclipse settings tomcat7 eclipse-juno

14
推荐指数
2
解决办法
2万
查看次数

收集整数列表(List <Integer>)以使用Java 8 Stream API进行映射

我想一个简单的转换List<Integer>Map使用Java 8个流API,并得到了以下编译时错误:

The method toMap(Function<? super T,? extends K>, Function<? super T,? 
extends U>) in the type Collectors is not applicable for the arguments 
(Function<Object,Object>, boolean)
Run Code Online (Sandbox Code Playgroud)

我的代码:

ArrayList<Integer> m_list = new ArrayList<Integer>();

m_list.add(1);
m_list.add(2);
m_list.add(3);
m_list.add(4);

Map<Integer, Boolean> m_map = m_list.stream().collect(
                Collectors.toMap(Function.identity(), true));
Run Code Online (Sandbox Code Playgroud)

我也尝试了下面的第二种方法,但得到了同样的错误.

Map<Integer, Boolean> m_map = m_list.stream().collect(
                Collectors.toMap(Integer::intValue, true));
Run Code Online (Sandbox Code Playgroud)

使用Java 8流API执行此操作的正确方法是什么?

collections arraylist hashmap java-8 java-stream

6
推荐指数
1
解决办法
885
查看次数

Spring Boot 2 NoSuchMethodException:org.springframework.mobile.device.Device.<init>()

最近我尝试将我的Spring Boot应用程序版本从1.5.10.RELEASE更新到2.0.0.RELEASE

项目环境

  • JDK 1.8版
  • Gradle中的jcenter()存储库
  • IDE Spring工具套件(STS)版本:3.9.2

我遇到过两个问题

  1. 我在下面得到了完成问题.

    无法解析配置':compileClasspath'的所有文件.找不到org.springframework.boot:spring-boot-starter-mobile:

    然后我检查了最新版本的spring-boot-starter-mobile库,并且Spring Boot 2没有稳定版本的spring-boot-starter-mobile.

    因此,我必须使用maven声明里程碑URL以导入版本:'2.0.0.M5'并且问题已解决.

    maven {url'https://repo.spring.io/milestone '}

    最初我使用的是jcenter(),是否可以使用jcenter导入里程碑?

  2. 访问下面的移动设备界面时,我收到以下运行时错误.

org.springframework.mobile.device.Device

public ResponseEntity<?> TestM(@RequestBody MyRequest myRequest, Device device) throws AuthenticationException {



    return ResponseEntity.ok();
}
Run Code Online (Sandbox Code Playgroud)

错误

2018-03-12 23:54:58.410 ERROR 13732 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: 
No primary or default constructor found for interface org.springframework.mobile.device.Device] with root cause

java.lang.NoSuchMethodException: org.springframework.mobile.device.Device.<init>()
    at java.lang.Class.getConstructor0(Unknown Source) ~[na:1.8.0_121] …
Run Code Online (Sandbox Code Playgroud)

mobile-devices spring-boot jcenter spring-boot-gradle-plugin

5
推荐指数
2
解决办法
3862
查看次数

Spring security - org.springframework.beans.factory.NoSuchBeanDefinitionException:没有定义名为'springSecurityFilterChain'的bean

我已经阅读了已经发布的大多数类似问题,但我仍然无法找到解决方案.请注意,常规CRUD应用程序正常工作.当我尝试通过spring-security添加登录功能时,我收到此错误.

我的工作环境如下;

1.Tomcat 7.0.35

2.Spring 3.2.0

3.Spring安全

弹簧安全配置,3.1.3.RELEASE.jar

弹簧安全核心3.1.3.RELEASE.jar

弹簧安全标签库,3.1.3.RELEASE.jar

弹簧安全网络3.1.3.RELEASE.jar

4.我的web.xml(/src/main/webapp/WEB-INF/web.xml)

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
            http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/root-context.xml</param-value>
</context-param>

<filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
</filter-mapping>


<!-- Processes application requests -->
<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:spring/conf/*-context.xml
        </param-value>
    </init-param>
    <!-- 
    <load-on-startup>1</load-on-startup>
     -->
</servlet>


<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)

5.我的security-context.xml(/src/main/resources/spring/conf/security-context.xml)

   <?xml version="1.0" encoding="UTF-8"?>

   <beans:beans xmlns="http://www.springframework.org/schema/security"
     xmlns:beans="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:p="http://www.springframework.org/schema/p" 
     xmlns:util="http://www.springframework.org/schema/util"
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/security 
    http://www.springframework.org/schema/security/spring-security-3.1.xsd
    http://www.springframework.org/schema/util 
    http://www.springframework.org/schema/util/spring-util-3.1.xsd">

<http pattern="/resources" security="none" />

<http auto-config="true" …
Run Code Online (Sandbox Code Playgroud)

web.xml spring-mvc spring-security tomcat7

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