GWT Maven Plugin — gwt:run works but gwt:compile d

2019-03-30 19:33发布

问题:

I'm using gwt-maven-plugin to manage a GWT project. I use the gwt:run goal all the time to run locally in "dev mode" for testing. I now want to compile my project into a war for deployment on Tomcat. When I run gwt:compile, however, I get compile errors that indicate a classpath configuration issue. An example:

Finding entry point classes
[ERROR] Errors in 'shared.MyClass.java'
[ERROR] Line 4: The import server.model.MyObject cannot be resolved

Any ideas? Do I need to manually add the server package to some config file somewhere? Thanks in advance for any info.

-tjw

回答1:

Ok, I found the problem. I found this in the GWT forums by Thomas Broyer (a GWT dev):

I mean you have to "javac" classes that are referenced from annotations (in this case, the PlaceTokenizer classes referenced from @WithTokenizers; that'd be true also of your service, domain object, locator or service locator with RequestFactory, unless you use @ServiceName and @ProxyForName). Otherwise, GWT can work with only the *.java files, without the *.class.

I am trying to load in these classes from annotations since they are used with RequestFactory. My question is now this: How is this restriction not completely insane?