隨筆 - 5  文章 - 17  trackbacks - 0
          <2008年3月>
          2425262728291
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          在我的范例工程中有如下類:

          import javax.persistence.*;

          import org.apache.commons.lang.builder.ToStringBuilder;
          import org.apache.commons.lang.builder.ToStringStyle;

          @Entity
          public class Product extends BaseObject {

              
          private static final long serialVersionUID = -7166739807708948462L;

              
          private Long id;
              
          private String code;
              
          private String name;

              @Id @GeneratedValue(strategy
          =GenerationType.AUTO)
              
          public Long getId() {
                  
          return id;
              }
              
          public void setId(Long id) {
                  
          this.id = id;
              }
              @Column(nullable
          =false, length=50, unique=true)
              
          public String getCode() {
                  
          return code;
              }
              
          public void setCode(String code) {
                  
          this.code = code;
              }
              @Column(nullable
          =false, length=50)
              
          public String getName() {
                  
          return name;
              }
              
          public void setName(String name) {
                  
          this.name = name;
              }

              @Override
              
          public int hashCode() {
                  
          final int prime = 31;
                  
          int result = 1;
                  result 
          = prime * result + ((code == null? 0 : code.hashCode());
                  result 
          = prime * result + ((id == null? 0 : id.hashCode());
                  result 
          = prime * result + ((name == null? 0 : name.hashCode());
                  
          return result;
              }

              @Override
              
          public boolean equals(Object obj) {
                  
          if (this == obj)
                      
          return true;
                  
          if (obj == null)
                      
          return false;
                  
          if (getClass() != obj.getClass())
                      
          return false;
                  
          final Product other = (Product) obj;
                  
          if (code == null) {
                      
          if (other.code != null)
                          
          return false;
                  } 
          else if (!code.equals(other.code))
                      
          return false;
                  
          if (id == null) {
                      
          if (other.id != null)
                          
          return false;
                  } 
          else if (!id.equals(other.id))
                      
          return false;
                  
          if (name == null) {
                      
          if (other.name != null)
                          
          return false;
                  } 
          else if (!name.equals(other.name))
                      
          return false;
                  
          return true;
              }

              @Override
              
          public String toString() {
                  ToStringBuilder sb 
          = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
                      .append(
          "code"this.code)
                      .append(
          "name"this.name);

                  
          return sb.toString();
              }
          }

          這個類沒有什么特別的地方,但運行mvn appfuse:gen -Dentity=Product為它生成CRUD相關的代碼時卻如下錯誤:

          [ERROR] FATAL ERROR
          [INFO] ------------------------------------------------------------------------
          [INFO] E:\USR\openstore\target\appfuse\generated-sources\src\test\resources\Product-sample-data.xml doesn't exist
          [INFO] ------------------------------------------------------------------------
          [INFO] Trace
          E:\USR\openstore\target\appfuse\generated-sources\src\test\resources\Product-sample-data.xml doesn't exist
                  at org.apache.tools.ant.taskdefs.LoadResource.execute(LoadResource.java:142)
                  at org.appfuse.tool.ArtifactInstaller.installSampleData(ArtifactInstaller.java:135)
                  at org.appfuse.tool.ArtifactInstaller.execute(ArtifactInstaller.java:47)
                  at org.appfuse.mojo.exporter.AppFuseGeneratorMojo.doExecute(AppFuseGeneratorMojo.java:262)
                  at org.appfuse.mojo.HibernateExporterMojo.execute(HibernateExporterMojo.java:138)
                  at org.appfuse.mojo.exporter.AppFuseGeneratorMojo.execute(AppFuseGeneratorMojo.java:202)
                  at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:493)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:463)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
                  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
                  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
                  at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:585)
                  at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
                  at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
                  at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
                  at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

          仔細查看了Product的源碼,沒有什么錯啊......配置文件也看不出有什么問題......其它類都能正常地生成代碼,就這個類死活不行。
          注意到運行mvn appfuse:remove -Dentity=Product的過程中有如下提示:

          [info] [AppFuse] Removing generated files (pattern: **/Product*.java)
          [info] [AppFuse] Removing sample data for DbUnit
          [info] [AppFuse] Removing Spring bean definitions
          [info] [AppFuse] Removing Struts views and configuring
          [info] [AppFuse] Removing generated files (pattern: **/model/*.xml)
          [info] [AppFuse] Removing generated files (pattern: **/webapp/action/*.xml)
          [info] [AppFuse] Removing generated files (pattern: Product*.jsp)

          其中多處有Product*字樣。想到項目中還有另一個類ProductCategory(已經為它生成了代碼),是不是兩個類之間有什么沖突?于是做如下嘗試:

          1.備份Product.java和ProductCategory.java
          2.運行mvn appfuse:remove -Dentity=ProductCategory刪除已經生成的ProductCategory相關的代碼
          3.運行mvn appfuse:remove -Dentity=Product刪除殘留的Product相關的代碼
          4.恢復Product.java和ProductCategory.java到原目錄中
          5.將類ProductCategory改名為Category,相應地將文件ProductCategory.java改名為Category.java
          6.運行mvn appfuse:gen -Dentity=Category
          7.運行mvn appfuse:gen -Dentity=Product

          以上所有的步驟均執行成功!表明對于AppFuse的maven plugin來說,類Product和ProductCategory之間確實存在沖突。問題雖然可以繞過,但涉及的兩個類的名稱都是合法的Java類名,這不能不說是AMP的一個缺陷,我已經在官方論壇上發了一個帖子,希望作者能盡快修復

          posted on 2008-03-06 11:52 雨奏 閱讀(1018) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 凤翔县| 锡林浩特市| 阜宁县| 若尔盖县| 疏附县| 嘉义市| 正阳县| 特克斯县| 云南省| 建湖县| 靖西县| 游戏| 靖江市| 清镇市| 天柱县| 洛川县| 湾仔区| 白城市| 潜山县| 杭州市| 健康| 三都| 波密县| 定安县| 当阳市| 海城市| 泰州市| 合作市| 拉孜县| 广昌县| 永清县| 高唐县| 凉城县| 新和县| 文成县| 大理市| 土默特右旗| 玛曲县| 石柱| 怀柔区| 丹阳市|