在ColdFusion11中使用java类 - CreateObject函数的java对象类型是未知的

Neo*_*nig 6 coldfusion railo cfwheels coldfusion-10

我有一些代码可以在Railo下运行,但我正试图让这个特定的应用程序在CF10和CF11上工作

这是一个cfWheels应用程序,我BCrypt.class/miscellaneous/目录中有一个文件.

在我的/events/onapplicationstart.cfm档案中,我有:

application.bCrypt = CreateObject( "java", "BCrypt", "/miscellaneous/" );
Run Code Online (Sandbox Code Playgroud)

这适用于Railo; 但在CF11中我得到了

The java object type is unknown for the CreateObject function.

Verify the type of your object when creating it and try again. 
Valid Types are : component | java | webservice | dotnet | com | corba | .NET


The error occurred in /Volumes/Documents/blah/public/events/onapplicationstart.cfm: line 8
Called from /Volumes/Documents/blah/public/wheels/global/cfml.cfm: line 111
Called from /Volumes/Documents/blah/public/wheels/events/onapplicationstart.cfm: line 388
6 : 
7 :     // BCrypt library
8 :     application.bCrypt = CreateObject( "java", "BCrypt", "/miscellaneous/" );
9 : 
10 :    // Application Specific settings
Run Code Online (Sandbox Code Playgroud)

我认为这只是一种语法问题?我可以在CF10/11上以这种方式调用.class文件吗?

Neo*_*nig 5

啊,谢谢大家.正如haxtbh 在评论中所说,问题是

Adobe CF的createObject只有两个参数.类型和类.

所以我需要把:

this.javaSettings = { LoadPaths = ["/miscellaneous"] };

在/config/app.cfm中

然后使用

CreateObject( "java", "BCrypt" );

在/events/onapplicationstart.cfm中

  • 默认情况下,ColdFusion服务器在第一次加载时缓存类文件,您可以选择每次使用`reloadOnChange ="true"作为参数之一重新加载新副本.在开发过程中它非常有用. (4认同)