Java error: java.lang.ClassNotFoundException:

Java error: java.lang.ClassNotFoundException:

首先声明我不是 Java 开发人员,而是需要为项目利用一小部分 Java 代码的 Python 开发人员。 :-)

也就是说,我收到以下错误:

Caused by: java.lang.ClassNotFoundException: CustomSecurePropertyPlaceholderModule

使用以下代码:

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


<domain:mule-domain xmlns="http://www.mulesoft.org/schema/mule/core"
                    xmlns:domain="http://www.mulesoft.org/schema/mule/ee/domain"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xmlns:spring="http://www.springframework.org/schema/beans"
                    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
                    xmlns:mule-ss="http://www.mulesoft.org/schema/mule/spring-security"
                    xmlns:context="http://www.springframework.org/schema/context"
                    xmlns:tls="http://www.mulesoft.org/schema/mule/tls"
                    xmlns:ss="http://www.springframework.org/schema/security"
                    xmlns:http="http://www.mulesoft.org/schema/mule/http"
                    xmlns:secure-property-placeholder="http://www.mulesoft.org/schema/mule/secure-property-placeholder"
                    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
                                        http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
                                        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
                                        http://www.mulesoft.org/schema/mule/ee/domain http://www.mulesoft.org/schema/mule/ee/domain/current/mule-domain-ee.xsd
                                        http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
                                        http://www.mulesoft.org/schema/mule/tls http://www.mulesoft.org/schema/mule/tls/current/mule-tls.xsd
                                        http://www.mulesoft.org/schema/mule/secure-property-placeholder http://www.mulesoft.org/schema/mule/secure-property-placeholder/current/mule-secure-property-placeholder.xsd
                                        http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.0.xsd">


    <spring:beans>
        <spring:bean id="secure-property-placeholder" class="CustomSecurePropertyPlaceholderModule">
            <spring:property name="encryptionAlgorithm" value="AES" />
            <spring:property name="encryptionMode" value="CBC" />
            <spring:property name="keyFilePath" value="keyfile.properties" />
            <spring:property name="locations" value="secure.properties"/>
            <spring:property name="ignoreResourceNotFound" value="true" />
            <spring:property name="ignoreUnresolvablePlaceholders" value="true" />
        </spring:bean>
    </spring:beans>


</domain:mule-domain>

我已确保 src/main/java 在 运行 配置中的构建路径上(文件 CustomSecurePropertyPlaceholderModule 位于此处)。我还看到 shared_resources/target/classes 也被设置为 运行 配置中的输出文件夹。知道为什么我仍然收到此错误吗?

在Java中,class通常是在包中。

喜欢,com.yourself.CustomSecurePropertyPlaceholderModule

尝试将您的 class(希望您有)放入 src/main/java/com/yourself,并在前面添加 package com.yourself;并使用

<spring:bean id="secure-property-placeholder" class="com.yourself.CustomSecurePropertyPlaceholderModule">