Q:How to load class in idea plugin developing?

Answered

I use velocity.jar provided by Jetbrain's SDK in my plugin project for rendering files.

When I add some classes to implement  interface named 'org.apache.velocity.runtime.directive.Directive' ,it doesn't work.

Following is error message:

org.apache.velocity.exception.VelocityException: Failed to load Directive: org.muzi.open.helper.service.tplengine.velocity.CapFirstFunc
at org.apache.velocity.runtime.RuntimeInstance.loadDirective(RuntimeInstance.java:1045)
at org.apache.velocity.runtime.RuntimeInstance.initializeDirectives(RuntimeInstance.java:961)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:264)
at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:93)

 

Class CapFirstFunc has implemented the Directive interface.

It means no class loader can load my classes.

I know that Velocity's classes are loaded by idea, but now I need Velocity to load my classes;

Do you guys have any ideas? I really need .

 

0
2 comments

Seems no way to solve it.

I add getter method in model class for capitalizing the first letter instead of implementing velocity's interface.

And I add a const  value '\n'  in VelocityContext instance for new line.

0

Try packaging your own copy of Velocity library in your plugin. It seems Velocity uses its own magic org.apache.velocity.util.ClassUtils#getClass

0

Please sign in to leave a comment.