如何配置 grails 类路径以添加“src/groovy”文件夹(Linux环境下)?
我目前正在将我的开发环境从 Windows 移植到 Linux。
在 Linux 下,我注意到目录
中与我的类相关的“未找到类”编译错误。 windows下,效果很好。
运行“grails run-app”时,这个“src/groovy”目录是否包含在 CLASSPATH 中?为什么它在 Windows 和 Linux 下的表现不同? (GRAILS_HOME
和 GROOVY_HOME
在两种环境中都定义)
有没有办法在日志中显示当前的 CLASSPATH?
最重要的是,我如何解决我的问题? (除非设置全局 CLASSPATH=
)
感谢您的帮助,
问候,
Fabien。
I am currently porting my development environment from Windows to Linux.
Under Linux, I noticed a "No class found" compilation error related to my classes in the directory <PROJECT_HOME>/src/groovy
. Under windows, it works fine.
Is this "src/groovy" directory included in the CLASSPATH
when running "grails run-app" ? Why does it behave differently under Windows and under Linux? (GRAILS_HOME
and GROOVY_HOME
are defined in both environments)
Is there a way to display the current CLASSPATH in the logs?
And most important, how do I solve my problem? (except by setting the global CLASSPATH=<PROJECT_HOME>/src/groovy
)
Thank you for your help,
Regards,
Fabien.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,使用 grails 命令时,src/groovy 和 src/java 会自动出现在类路径中。我建议确保您的包语句正确,并且错误不是指您的代码引用的内容。
Yes, src/groovy and src/java are automatically in the classpath when using the grails commands. I would recommend making sure your package statements are correct and that the error isn't referring to something your code is referencing.
在 Windows 上进行
grails clean
后,代码仍然有效吗?我想知道您是否已经重构并且旧版本仍在您的类目录中运行。否则,根据您的预期验证 .class 文件的大小写(如 John W. 建议的那样)。
请记住,Linux 文件系统通常区分大小写,而 Windows 则不区分大小写(无论如何默认情况下)。
您能否发布您所看到的异常?
Does the code still work after you do a
grails clean
on Windows?I wonder if you have refactored and have an old version still kicking around in your classes directory. Otherwise verify the case of the .class files with what you expect (as John W. suggested).
Keep in mind that Linux file systems are typically case-sensitive where Windows is not (by defauly anyway).
Could you post the exception that you are seeing?
CLASSPATH 不适用于源代码,而是用于编译的二进制类。您需要设置您的项目而不是 Grails。
您可以从
grails console
检查Grails环境 - 例如,评估System.getProperty("java.class.path")
。控制台是否运行?这可能是您的文件夹结构或权限的问题 - 您可以检查 src/groovy 所有者和权限吗,它可能由其他用户拥有?
CLASSPATH
is not for sources but for compiled, binary classes. You need to set up your project and not Grails.You can examine Grails environment from
grails console
- for instance, evaluateSystem.getProperty("java.class.path")
. Does Console run at all?It might be an issue with your folder structure or permissions - can you check
src/groovy
owner and rights, it might be owned by another user?