问题标签 [ninjaframework]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - Ninja framework Install Error with Maven
I'm trying to learn Ninja framework for building RESTful web services at here
I got the following error when I run "mvn clean install" inside the newly created maven project folder:
I am on Mac Mavericks with Java 8, if this matters. Thanks
json - Ninja framework not getting POST data or seeing NinjaProperties
Two things are going wrong here, which might be two problems or might have the same root: they both feel like a config error somewhere, hence putting them together. Apologies is advance if this is confusing the issue...
I'm using Ninja Framework, still learning my way around starting from the Hello World example. I can serve pages with GET and POST using Routes, a Controller and html OK.
In case it is relevant, I'm running on a fresh CentOS VM, using NetBeans to write, Firefox to test. I have restarted Ninja (many times).
Problem 1: NinjaProperties isn't visible in code. I had understood that I can put, for example
and have my model code access the application.conf file to extract properties. However ninjaProperties is coming back null.
Problem 2: The JSON parsing described at Ninja docs where adding a simple class with the right field names to the controller signature caused JSON to be translated behind the scenes isn't working. I can add the class, with the right fields, to the Controller method signature but it is always null. Using GSON I can extract the object for myself so I have a work-around but that also confirms that it is something in Ninja that isn't working.
The code follows the example pretty closely:
}
and
Any ideas? Thanks in advance...
java - Ninja Framework 以自定义格式返回 JSON
我们如何在 NINJA FRAMEWORK 控制器中返回 JSON 时返回自定义格式的 JSON。
我的POJO类
当前 JSON 输出
自定义 JSON 输出(必需)
java - 如何安装第一个 Ninja Web Framework 应用程序?
我正在尝试安装出现在这里的第一个 Ninja Web Framework 应用程序,但我收到了失败的测试错误。我的java版本是
我的 Maven 版本是
我输入后收到的错误mvn3 clean install
是:
关于什么是错的以及如何解决它的任何想法?
java - 如何拆分 ninjaframework-web-application?
我刚刚开始开发基于 ninjaframework 的 java web 应用程序。一切都很好,但是:有了所有 ninja-dependencies,deploy-war 大约有 25MB。我真的希望,我不必一直上传 25MB 的 java 存档——尤其是因为依赖项不会像我的应用程序的样式表那样经常更改。
是否有实用的解决方案将 ninjaframework-dependencies 移动到单独的 jar 中?我正在使用 eclipse,因此集成在 IDE 中的解决方案会很棒。
到目前为止,我已经查看了 maven 依赖范围,并且(未成功)尝试将依赖项移动到一个单独的项目中,并使用系统范围的依赖项来引用该项目(据我所知,它能够部署作为一个单独的 jar 文件)。我目前无法使用 maven 构建这个依赖项 - 但我也想知道是否有更好的方法。
我将应用程序部署在 plesk 安装中的 tomcat 服务器上
java - 过滤器中的 Ninja Framework JSR303Validation
我正在开发一个基于 Ninja JSON 的应用程序,我在其中跨多个控制器方法实现 @JSR303Validation 注释。我目前正在通过传入 Validation 对象并调用validation.hasBeanViolations()
以查看是否有故障来检查控制器本身的验证。如果有,我将向客户端返回失败的结果。
我不想在控制器中执行此操作,而是想使用过滤器验证请求。但是,我不知道该怎么做?有人可以帮忙吗?据我所知,您不能将验证作为参数传递给过滤器,并且 context.getValidation() 对象似乎没有发现任何验证失败。
java - javax.mail.SendFailedException 为什么当我尝试通过我的 java 代码发送电子邮件时收到上述异常?
我想编写一个 java 程序来从我的电子邮件地址向任何电子邮件地址发送电子邮件,但是当我运行我的代码时,我得到了这个 javax.mail.SendFailedException。我的代码有 2 个类 Main.java 和 EmailManagement.java。我收到的错误是:
代码如下。
导入 javax.swing.JOptionPane;
java - 是否可以通过编程方式创建 Freemarker 宏?
Freemarker 被用作 ninja web 框架中的默认模板引擎。该框架为使用 ninja web 框架时全局可用的模板分配了一些默认值。我已经为启用 CSRF-Protection 的模板创建了一个扩展。该扩展提供了一个可以在模板中使用的功能,例如
目前需要使用特定的参数调用该函数,这不是很直观。使用宏我可以简化这个调用
并且用户无需担心传递正确的(例如“bar”)参数。但是为了让这个在 ninja web 框架中可用,我必须以编程方式定义一个宏。那可能吗?
更新
对困惑感到抱歉。意思是 <@foo/> 而不是 @{foo} ...
查看 Freemarker 文档,我也许可以更清楚地了解我想要实现的目标:http: //freemarker.org/docs/ref_directive_macro.html
就像我上面解释的那样,我将自定义函数传递给模板,使我能够调用
我想做的是通过一个宏来调用它
但是定义的宏就像
不应在模板中定义,而是以编程方式定义。希望这能让它更清楚。
更新2/解决方案
我最终使用了推荐的 TemplateDirectiveModel。
java - Ninja 框架包括外部 Jar
我有一个希望添加到我的忍者框架应用程序的外部 jar。
我已将文件包含在根目录中,但不起作用。
我还尝试使用 IntelliJ IDE 将其作为依赖项包含在内。
这也没有奏效。在部署到 heroku 时,编译失败,因为找不到包。
最后,我尝试了这个https://devcenter.heroku.com/articles/local-maven-dependencies#deploy-the-artifact-into-the-repo,但失败并显示以下错误消息:
任何人都可以提出其他建议吗?
谢谢
java - 忍者框架中的表未映射错误
我正在为一个简单的 webapp 使用 ninjaframework。
我在mysql中有下表:
在我的 DAO 中,我有以下代码:
这会导致以下错误:
我确实有一个看起来像这样的事件类:
为什么我会收到此错误?stackoverflow 上的大多数线程建议我应该修改休眠配置。但是,我没有任何休眠配置文件,因为 ninja 不需要它。