Anypoint Studio FileNotFoundException:无法打开类路径资源[app.properties],因为它不存在

时间:2018-02-19 17:15:25

标签: mule config filenotfoundexception anypoint-studio

我在使用Anypoint Studio项目时遇到了问题,它在几天前就已经运行了,但现在却抛出了FileNotFoundException错误。我环顾四周,知道我的文件必须在我项目的资源文件夹中。但它仍然抛出错误,我不知道为什么。有谁能指导我?

我的项目:

enter image description here

我项目的配置XML:

enter image description here

org.mule.module.launcher.DeploymentInitException: FileNotFoundException: class path resource [app.properties] cannot be opened because it does not exist
at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:197) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.artifact.ArtifactWrapper$2.execute(ArtifactWrapper.java:62) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:129) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.artifact.ArtifactWrapper.init(ArtifactWrapper.java:57) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:25) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DefaultArchiveDeployer.guardedDeploy(DefaultArchiveDeployer.java:324) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:345) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:163) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:268) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:83) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DeploymentDirectoryWatcher.deployPackedApps(DeploymentDirectoryWatcher.java:275) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:150) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.MuleDeploymentService.start(MuleDeploymentService.java:104) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.MuleContainer.start(MuleContainer.java:170) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:15) ~[tooling-support-3.7.3.jar:?]
Caused by: org.mule.api.config.ConfigurationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [app.properties] cannot be opened because it does not exist (org.mule.api.lifecycle.InitialisationException) (org.mule.api.config.ConfigurationException)

3 个答案:

答案 0 :(得分:0)

  • 尝试classpath:app.properties
  • 同时删除并重新导入工作区中的项目

答案 1 :(得分:0)

一般情况下,企业级应用程序将在域级别和服务级别具有项目。当我们从存储库中检出域项目,并开始仅构建域项目(使用Maven将域项目作为mule运行)时,它将尝试属性文件和失败。在那种情况下抛出了这个异常。

解决方案:与域一起签出Services项目,并开始构建项目,不会抛出此异常。项目应该成功建立。 确保正确设置JRE和Maven设置并运行mvn clean build。

答案 2 :(得分:0)

尝试创建属性占位符

this.sqlite.create({
            name: 'addresses.db',
            location: 'default'
        }).then((db: SQLiteObject) => {
            db.executeSql('INSERT INTO experiences VALUES(?,?,?,?,?)',[name, country, state, city, experience])
            .then(res => {
                console.log('Data Saved into Experiences Table!');
            })
            .catch(e => {
                console.log(e);
            });
        }).catch(e => {
            console.log(e);
        });

参考:Accessing mule-app.properties in custom properties file located in src/main/resources on cloudhub