小编Abi*_*san的帖子

Spring Autowire 原始布尔值

我的 XML 配置包括这些 bean 定义:

<bean id="abstractFormAction" class="staffing.server.action.form.AbstractFormAction" abstract="true" parent="baseAction">
    <property name="volunteerSaver" ref="volunteerSaver"/>
    <property name="emailSender" ref="emailSender"/> 
    <property name="closed" value="${form.closed}"/>
</bean>

<bean id="volunteerFormAction" class="staffing.server.action.form.VolunteerFormAction" parent="abstractFormAction">
    <property name="captchaGenerator" ref="captcha"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

表示VolunteerFormAction是AbstactFormAction的具体实现,会继承AbstactFormAction的属性。

在 AbstractFormAction 中,我声明了这样的属性:

@Autowired protected VolunteerSaver volunteerSaver;
@Autowired protected EmailSender emailSender;
@Autowired protected boolean closed;
Run Code Online (Sandbox Code Playgroud)

尝试部署时出现以下异常:

org.springframework.beans.factory.BeanCreationException:创建名为“volunteerFormAction”的 bean 时出错:自动装配依赖项的注入失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:受保护的布尔值 staffing.server.action.form.AbstractFormAction.closed; 嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException: 找不到类型 [boolean] 的匹配 bean 依赖项:预期至少有 1 个 bean 有资格作为此依赖项的自动装配候选者。依赖注解:{@org.springframework.beans.factory.annotation.Autowired(required=true)}

它似乎在抱怨它找不到字节布尔值的 bean。但是,当定义了按值而不是按引用“关闭”的属性时,为什么它需要一个 bean?

java spring autowired

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

无法获得sort-map-by并一起应用工作

我在使用带有sorted-map-by和apply的自定义比较器时遇到了问题.如何使下面的表达式工作 -

(apply sorted-map-by > {1 "ab" 3 "cs" 2 "vs"})
Run Code Online (Sandbox Code Playgroud)

我得到以下例外 -

IllegalArgumentException没有为key提供的值:[3"cs"] clojure.lang.PersistentTreeMap.create(PersistentTreeMap.java:87)

clojure

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

WSO2 ESB 4.6.0中Spring Mediator的工作示例

你好我工作的弹簧调解员WSO2 ESB 4.6.0,使用教程

我收到错误如下:

ERROR - SpringMediator Cannot look up Spring configuration conf/sample/resources/spring/springsample.xml

ERROR - SpringMediatorCannot reference application context with key : conf/sample/resources/spring/springsample.xml
Run Code Online (Sandbox Code Playgroud)

你能解释一下如何解决这个问题.

spring wso2 apache-synapse wso2esb wso2carbon

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

WSO2 API Manager,是否可以禁用访问令牌机制

是否可以在WSO2 API Manager中禁用访问令牌机制?所以我们不必设置身份验证承载头.我知道我可以将访问令牌超时设置为-1秒,以使其无限.

wso2 wso2-api-manager

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

WSO2:寄存器中的内联XML条目 - 如何删除命名空间

我是WSO2 ESB产品的新手,我正在尝试使用商店XML消息模板的本地注册表项.我注意到,当我使用"Add In-Lined XML Entry"保存资源时,始终会将synapse名称空间添加到根元素中.有没有什么方法可以避免这种情况?...或者,当我在调解员中引用该键时,我可以将其删除?考虑一下我的目标是在富集中介中使用该引用.谢谢并问候工厂

wso2 wso2esb

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

我可以在我的超类中使用子类的名称吗?

我有超类,看起来像:

 public abstract class Fish {

 protected int size;

 protected float weight;

 //constructor

 public Fish(int s, float w) {
 size = aSize;weight = aWeight;}
Run Code Online (Sandbox Code Playgroud)

我有这个超类的2个子类.第一:

 public class SomeFish extends Fish{

 //constructor

 public SomeFish(int s, float w) {

 super(s, w) }
Run Code Online (Sandbox Code Playgroud)

第二个:

public class AnotherFish extends Fish{

 //constructor

 public AnotherFish(int s, float w) {

 super(s, w) }
Run Code Online (Sandbox Code Playgroud)

我要做的是在Fish类中编写一个String toString方法,返回类似于:12 cm 0.5 这里应该是适当类型的鱼(AnotherFish或SomeFish).我可以不使用字符串toString方法抽象并在SomeFish和AnotherFish类中实现字符串toString方法吗?

java subclass superclass

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

arraylist 找不到符号:方法 addLast

在声明 ArrayList 后,我​​在使用 addLast 方法时遇到问题。这是类代码:

import java.util.*;

public class Neuron{

        public int m_numInputs;
        public ArrayList<Double> m_vecWeight = new ArrayList<Double>();

        public Neuron(int numInputs){
                this.m_numInputs = numInputs + 1;

                //additional weight for bias
                for(int i = 0; i < numInputs + 1; ++i){
                        Random rand = new Random();
                        m_vecWeight.addLast(rand.nextFloat() * 2.0 - 1.0);

                }
        }

}
Run Code Online (Sandbox Code Playgroud)

所以我得到的错误是:

cannot find symbol: method addLast(double), location: variable m_vecWeight of type ArrayList<Double>
Run Code Online (Sandbox Code Playgroud)

任何指导将不胜感激。

java

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

如何在WSO2 ESB REST API中更改HTTP状态代码

我有一个使用WSO2 ESB创建的rest api.我想在请求的API资源与给定URL不匹配时将HTTP状态代码更改为404.目前我收到了'HTTP/1.1 202 Accepted'回复.我的esb版本是4.0.3.

rest wso2 wso2esb

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

将priorityQueue转换为我的自定义界面

public class testCast {

    public interface dataQueue extends Queue<Object>{};

    public static void main (String test[]){        
        dataQueue queue = (dataQueue) new java.util.PriorityQueue<Object>();
        queue.add("Test");
        System.out.println(queue.peek());
    }
}
Run Code Online (Sandbox Code Playgroud)

我想知道为什么这会导致出现错误....如果我这样做会有效

Queue queue = (Queue) new java.util.PriorityQueue<Object>(); 有谁知道为什么?提前致谢

java

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

在Java中从字符串中删除字符

我有一个字符串,我需要从中删除某个字符,我已经能够做到这一点,但我仍然有问题。我去掉了字符,但字符串的长度保持不变。

public class HelloWorld{

   public static void main(String []args){
       String data = "Hello World";
       System.out.println(data);
       System.out.println("string length: " + data.length());
       char letter = 'l';
       data = data.replace(letter, '\0');
       System.out.println(data);
       System.out.println("string length: " + data.length());
    }
 }
Run Code Online (Sandbox Code Playgroud)

这给了我输出:

Hello World

string length: 11

Heo Word

string length: 11
Run Code Online (Sandbox Code Playgroud)

我需要它是:

Hello World

string length: 11

Heo Word

string length: 8
Run Code Online (Sandbox Code Playgroud)

为什么它似乎在计算字符串中不再存在的字符?

java string

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