问题
I'm trying to learn Spring Roo. One of the thing I wanted to try is what web mvc json setup
is doing, but I'm getting message:
Command 'web mvc json setup' was found but is not currently available (type 'help' then ENTER to learn about this command)
which is not helping at all. I found nothing in docs.
Steps I did in console
C:\Betlista\tmp>mkdir RooJSONTest
C:\Betlista\tmp>cd RooJSONTest
C:\Betlista\tmp\RooJSONTest>roo
____ ____ ____
/ __ \/ __ \/ __ \
/ /_/ / / / / / / /
/ _, _/ /_/ / /_/ /
/_/ |_|\____/\____/ 1.3.2.RELEASE [rev 8387857]
Welcome to Spring Roo. For assistance press TAB or type "hint" then hit ENTER.
Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
roo> project --topLevelPackage betlista.tests.roo.json --
project --topLevelPackage betlista.tests.roo.json --java project --topLevelPackage betlista.tests.roo.json --packaging
project --topLevelPackage betlista.tests.roo.json --parent project --topLevelPackage betlista.tests.roo.json --projectName
roo> project --topLevelPackage betlista.tests.roo.json --projectName RooJSONTest
Created ROOT\pom.xml
Created SRC_MAIN_RESOURCES
Created SRC_MAIN_RESOURCES\log4j.properties
Created SPRING_CONFIG_ROOT
Created SPRING_CONFIG_ROOT\applicationContext.xml
roo> web mvc setup
Created ROOT\src\main\webapp\WEB-INF\spring
Created ROOT\src\main\webapp\WEB-INF\spring\webmvc-config.xml
Created ROOT\src\main\webapp\WEB-INF\web.xml
Updated ROOT\src\main\webapp\WEB-INF\spring\webmvc-config.xml
Created ROOT\src\main\webapp\images
Created ROOT\src\main\webapp\images\add.png
Created ROOT\src\main\webapp\images\banner-graphic.png
Created ROOT\src\main\webapp\images\create.png
Created ROOT\src\main\webapp\images\delete.png
Created ROOT\src\main\webapp\images\favicon.ico
Created ROOT\src\main\webapp\images\list.png
Created ROOT\src\main\webapp\images\resultset_first.png
Created ROOT\src\main\webapp\images\resultset_last.png
Created ROOT\src\main\webapp\images\resultset_next.png
Created ROOT\src\main\webapp\images\resultset_previous.png
Created ROOT\src\main\webapp\images\show.png
Created ROOT\src\main\webapp\images\springsource-logo.png
Created ROOT\src\main\webapp\images\update.png
Created ROOT\src\main\webapp\styles
Created ROOT\src\main\webapp\styles\alt.css
Created ROOT\src\main\webapp\styles\standard.css
Created ROOT\src\main\webapp\WEB-INF\classes
Created ROOT\src\main\webapp\WEB-INF\classes\alt.properties
Created ROOT\src\main\webapp\WEB-INF\classes\standard.properties
Created ROOT\src\main\webapp\WEB-INF\layouts
Created ROOT\src\main\webapp\WEB-INF\layouts\default.jspx
Created ROOT\src\main\webapp\WEB-INF\layouts\layouts.xml
Created ROOT\src\main\webapp\WEB-INF\views
Created ROOT\src\main\webapp\WEB-INF\views\header.jspx
Created ROOT\src\main\webapp\WEB-INF\views\menu.jspx
Created ROOT\src\main\webapp\WEB-INF\views\footer.jspx
Created ROOT\src\main\webapp\WEB-INF\views\views.xml
Created ROOT\src\main\webapp\WEB-INF\views\dataAccessFailure.jspx
Created ROOT\src\main\webapp\WEB-INF\views\index-template.jspx
Created ROOT\src\main\webapp\WEB-INF\views\index.jspx
Created ROOT\src\main\webapp\WEB-INF\views\resourceNotFound.jspx
Created ROOT\src\main\webapp\WEB-INF\views\uncaughtException.jspx
Created ROOT\src\main\webapp\WEB-INF\tags\form
Created ROOT\src\main\webapp\WEB-INF\tags\form\create.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\dependency.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\find.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\list.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\show.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\update.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\fields
Created ROOT\src\main\webapp\WEB-INF\tags\form\fields\checkbox.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\fields\column.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\fields\datetime.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\fields\display.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\fields\editor.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\fields\input.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\fields\reference.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\fields\select.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\fields\simple.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\fields\table.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\form\fields\textarea.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\menu
Created ROOT\src\main\webapp\WEB-INF\tags\menu\category.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\menu\item.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\menu\menu.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\util
Created ROOT\src\main\webapp\WEB-INF\tags\util\language.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\util\load-scripts.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\util\pagination.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\util\panel.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\util\placeholder.tagx
Created ROOT\src\main\webapp\WEB-INF\tags\util\theme.tagx
Created ROOT\src\main\webapp\WEB-INF\i18n
Created ROOT\src\main\webapp\WEB-INF\i18n\messages.properties
Created ROOT\src\main\webapp\images\en.png
Updated ROOT\src\main\webapp\WEB-INF\i18n\application.properties
Updated ROOT\src\main\webapp\WEB-INF\web.xml
Updated ROOT\pom.xml [added dependencies org.springframework:spring-webmvc:${spring.version}, org.springframework.webflow:spring-js-resources:2.2.1.RELEASE, commons-digester:commons-digester:2.1, commons-fileupload:commons-fileupload:1.2.2, javax.servlet.jsp.jstl:jstl-api:1.2, org.glassfish.web:jstl-impl:1.2, javax.el:el-api:2.2, joda-time:joda-time:1.6, javax.servlet.jsp:jsp-api:2.1, commons-codec:commons-codec:1.5; updated project type to war; added property 'tomcat.version' = '7.0.63'; added plugin org.apache.tomcat.maven:tomcat7-maven-plugin:2.2; added plugin org.mortbay.jetty:jetty-maven-plugin:8.1.4.v20120524; added dependency org.apache.tiles:tiles-jsp:2.2.2]
Updated SRC_MAIN_WEBAPP\WEB-INF\views\footer.jspx
roo> web mvc json setup
Command 'web mvc json setup' was found but is not currently available (type 'help' then ENTER to learn about this command)
回答1:
I have found the following link: http://dodero.github.io/sosc-wmf/Configuring%20JSON%20remoting.html
They describe the issue as follows:
..."Due to a still unsolved issue in Spring ROO, generating JSON controllers with web mvc json setup does not work anymore after running once web mvc setup to generate regular web controllers..."
A clean solution would be to delete the project and start over with " project --topLevelPackage..." but this time WITHOUT running "web mvc setup".
Otherwise you might also try their suggested solution:
"...To solve that issue, the @RooWebJson tag can be added to the controller (e.g. PizzaController), and ROO will automatically generate the Aspect that adds the JSON implementation..."
but it didn't work for me. Hope i could help.
回答2:
As you could check on Spring Roo code, command web mvc json setup
will be available only if a project is created and if Spring MVC
and JSF
features has not been installed on current project.
public boolean isWebJsonInstallationPossible() {
return !projectOperations
.isFeatureInstalledInFocusedModule(FeatureNames.MVC)
&& !projectOperations
.isFeatureInstalledInFocusedModule(FeatureNames.JSF)
&& projectOperations.isFocusedProjectAvailable();
}
In your provided example, you are executing web mvc setup
before to execute web mvc json setup
so (checking code above) thats the reason of the not found
message.
Try to execute web mvc json setup
command instead of web mvc setup
.
Regards,
来源:https://stackoverflow.com/questions/34557206/spring-roo-add-json