SpringSide实战(三)----使用SpringSide4自动构建一个项目

SpringSide4为我们提供了一个自动生成WEB项目的骨架,它使用的是Maven的Archetype插件,基于Quickstart项目,创建自己的项目。


一、安装模块


首先进入support/maven-archetype目录下




执行install.bat,进行安装,输出如下:


[INFO] Install archetype to local repository.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SpringSide :: Archetype :: QuickStart 4.2.2.GA
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ quickstart-archetype ---
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ quickstart-archetype ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 83 resources
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ quickstart-archetype ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory F:\Youku Files\springside4-4.2.2.GA\support\maven-archetype\src\test\resources
[INFO]
[INFO] --- maven-archetype-plugin:2.2:jar (default-jar) @ quickstart-archetype ---
[INFO] Building archetype jar: F:\Youku Files\springside4-4.2.2.GA\support\maven-archetype\target\quickstart-archetype-4.2.2.GA
[INFO]
[INFO] --- maven-archetype-plugin:2.2:integration-test (default-integration-test) @ quickstart-archetype ---
[WARNING] No Archetype IT projects: root 'projects' directory not found.
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ quickstart-archetype ---
[INFO] Installing F:\Youku Files\springside4-4.2.2.GA\support\maven-archetype\target\quickstart-archetype-4.2.2.GA.jar to F:\MAV\MavenRepository\MavenRepositorys\org\springside\examples\quickstart-archetype\4.2.2.GA\quickstart-archetype-4.2.2.GA.jar
[INFO] Installing F:\Youku Files\springside4-4.2.2.GA\support\maven-archetype\pom.xml to F:\MAV\MavenRepository\MavenRepositorys\org\springside\examples\quickstart-archetype\4.2.2.GA\quickstart-archetype-4.2.2.GA.pom
[INFO]
[INFO] --- maven-archetype-plugin:2.2:update-local-catalog (default-update-local-catalog) @ quickstart-archetype ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.523 s
[INFO] Finished at: 2017-06-04T21:51:35+08:00
[INFO] Final Memory: 14M/155M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "nexus" could not be activated because it does not exist.

二、自动生成


双击根目录中的generate-project.bat 




报错:


[INFO] Generating project in ./generated-projects
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[WARNING] No archetype found in remote catalog. Defaulting to internal catalog
[WARNING] Archetype not found in any catalog. Falling back to central repository.
[WARNING] Add a repsoitory with id 'archetype' in your settings.xml if archetype's repository is elsewhere.
[WARNING] The POM for org.springside.examples:quickstart-archetype:jar:4.1.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25.062 s
[INFO] Finished at: 2017-06-04T21:55:02+08:00
[INFO] Final Memory: 15M/167M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "nexus" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: The desired archetype does not exist (org.springside.examples:quickstart-archetype:4.1.1-SNAPSHOT) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

提示:

Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: The desired archetype does not exist (org.springside.examples:quickstart-archetype:4.1.1-SNAPSHOT)


修改generate-project.bat中的-DarchetypeVersion=4.1.1-SNAPSHO为4.2.2.GA,因为上面安装的就是4.2.2.GA。他这里写错了。修改好之后如下:


@echo off
echo [INFO] Generating project in ./generated-projects

if not exist  generated-projects mkdir generated-projects
cd generated-projects
call mvn archetype:generate -DarchetypeGroupId=org.springside.examples -DarchetypeArtifactId=quickstart-archetype -DarchetypeVersion=4.2.2.GA

pause

再次执行generate-project.bat,就会出现交互信息:




1.groupId,如com.fendo
2.artifactId,如myfendo
3.version,如1.0.0-SNAPSHOT
4.package,如com.fendo.myfendo,注意此处最好是groupId+artifactId的组合,而不是默认的groupId.

最后再输入Quickstart模板的一个特有的属性:

tablePrefix,用于在数据库表中加上前缀,如my_


新项目就会生成在./genterated-projects里




三、手动生成


手动输入: 


mvn archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=org.springside.examples -DarchetypeArtifactId=quickstart-archetype -DarchetypeVersion=4.2.2.GA

生成如下:




四、基于一个已经存在的项目生成


在examples下新建archetype.properties文件,内容为:


tablePrefix=ss_


ablePrefix是QucikStart项目里用到的,想在新项目中替换掉的内容。

-DfilteredExtentions,因为maven默认不会扫描sql文件,而这里是希望修改tablePrefix的.


然后执行命令:


mvn clean archetype:create-from-project -Darchetype.properties=./archetype.properties -Darchetype.filteredExtentions=java,xml,jsp,properties,sql


生成如下:




生成出来的是个毛坯房,需要一些修改,比如test/functional并不智能,需要手工将package目录去掉,然后修改archetype-metadata.xml在test/functional加上packaged="true", 比如archetype-metadata.xml中的default值要去掉等等,需要手工耐心测试。


五、eclipse生成


因为上面已经把springside得一些module已经安装到本地来了,所以在eclipse可以找到springside的archetype




点击Next




生成如下:





六、一些错误


在安装过程中报了一堆错。。。

[INFO] Install archetype to local repository.
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-packaging/2.2/archetype-packaging-2.2.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-packaging/2.2/archetype-packaging-2.2.pom (0 B at 0.0 KB/sec)
[WARNING] The POM for org.apache.maven.archetype:archetype-packaging:jar:2.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-packaging/2.2/archetype-packaging-2.2.jar
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-packaging/2.2/archetype-packaging-2.2.jar (0 B at 0.0 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar (0 B at 0.0 KB/sec)
[ERROR] Invalid extension descriptor for org.apache.maven.archetype:archetype-packaging:2.2: error in opening zip file
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unknown packaging: maven-archetype @ line 8, column 14
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project org.springside.examples:quickstart-archetype:4.2.2.GA (F:\Youku Files\springside4-4.2.2.GA_OK\springside4-4.2.2.GA\support\maven-archetype\pom.xml) has 1 error
[ERROR]     Unknown packaging: maven-archetype @ line 8, column 14
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException


这种错是由于网络引起的,下载jar没下载下来。


还有下面这种错,也是由于jar没下全引起的


[INFO] Generating project in ./generated-projects
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---
[WARNING] Error initializing: org.codehaus.plexus.velocity.DefaultVelocityComponent@1162410a
java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
at org.apache.velocity.runtime.resource.ResourceManagerImpl.initialize(ResourceManagerImpl.java:161)
at org.apache.velocity.runtime.RuntimeInstance.initializeResourceManager(RuntimeInstance.java:730)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:263)
at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:93)
at org.codehaus.plexus.velocity.DefaultVelocityComponent.initialize(DefaultVelocityComponent.java:95)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.initialize(PlexusLifecycleManager.java:303)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.activate(PlexusLifecycleManager.java:207)
......................
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
... 204 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.080 s
[INFO] Finished at: 2017-06-03T12:54:49+08:00
[INFO] Final Memory: 11M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate failed: A required class was missing while executing org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate: org/apache/commons/lang/StringUtils
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-archetype-plugin:3.0.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/E:/MavenRepository/org/apache/maven/plugins/maven-archetype-plugin/3.0.1/maven-archetype-plugin-3.0.1.jar
[ERROR] urls[1] = file:/E:/MavenRepository/org/apache/maven/archetype/archetype-catalog/3.0.1/archetype-catalog-3.0.1.jar
[ERROR] urls[2] = file:/E:/MavenRepository/org/apache/maven/archetype/archetype-descriptor/3.0.1/archetype-descriptor-3.0.1.jar
[ERROR] urls[3] = file:/E:/MavenRepository/org/apache/maven/archetype/archetype-common/3.0.1/archetype-common-3.0.1.jar
[ERROR] urls[4] = file:/E:/MavenRepository/net/sourceforge/jchardet/jchardet/1.0/jchardet-1.0.jar
[ERROR] urls[5] = file:/E:/MavenRepository/org/codehaus/plexus/plexus-component-annotations/1.6/plexus-component-annotations-1.6.jar
[ERROR] urls[6] = file:/E:/MavenRepository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
[ERROR] urls[7] = file:/E:/MavenRepository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
[ERROR] urls[8] = file:/E:/MavenRepository/jdom/jdom/1.0/jdom-1.0.jar
[ERROR] urls[9] = file:/E:/MavenRepository/commons-io/commons-io/2.2/commons-io-2.2.jar
[ERROR] urls[10] = file:/E:/MavenRepository/org/codehaus/plexus/plexus-velocity/1.1.8/plexus-velocity-1.1.8.jar
[ERROR] urls[11] = file:/E:/MavenRepository/org/apache/velocity/velocity/1.7/velocity-1.7.jar
[ERROR] urls[12] = file:/E:/MavenRepository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
[ERROR] urls[13] = file:/E:/MavenRepository/org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.jar
[ERROR] urls[14] = file:/E:/MavenRepository/antlr/antlr/2.7.7/antlr-2.7.7.jar
[ERROR] urls[15] = file:/E:/MavenRepository/asm/asm/3.2/asm-3.2.jar
[ERROR] urls[16] = file:/E:/MavenRepository/asm/asm-commons/3.2/asm-commons-3.2.jar
[ERROR] urls[17] = file:/E:/MavenRepository/asm/asm-util/3.2/asm-util-3.2.jar
[ERROR] urls[18] = file:/E:/MavenRepository/asm/asm-analysis/3.2/asm-analysis-3.2.jar
[ERROR] urls[19] = file:/E:/MavenRepository/asm/asm-tree/3.2/asm-tree-3.2.jar
[ERROR] urls[20] = file:/E:/MavenRepository/org/codehaus/plexus/plexus-utils/3.0.21/plexus-utils-3.0.21.jar
[ERROR] urls[21] = file:/E:/MavenRepository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-6/plexus-interactivity-api-1.0-alpha-6.jar
[ERROR] urls[22] = file:/E:/MavenRepository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar
[ERROR] urls[23] = file:/E:/MavenRepository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar
[ERROR] urls[24] = file:/E:/MavenRepository/org/apache/maven/maven-aether-provider/3.0/maven-aether-provider-3.0.jar
[ERROR] urls[25] = file:/E:/MavenRepository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar
[ERROR] urls[26] = file:/E:/MavenRepository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[27] = file:/E:/MavenRepository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[28] = file:/E:/MavenRepository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[29] = file:/E:/MavenRepository/org/apache/maven/shared/maven-invoker/2.2/maven-invoker-2.2.jar
[ERROR] urls[30] = file:/E:/MavenRepository/org/apache/maven/shared/maven-artifact-transfer/0.9.0/maven-artifact-transfer-0.9.0.jar
[ERROR] urls[31] = file:/E:/MavenRepository/org/apache/maven/shared/maven-common-artifact-filters/3.0.0/maven-common-artifact-filters-3.0.0.jar
[ERROR] urls[32] = file:/E:/MavenRepository/org/apache/maven/shared/maven-shared-utils/3.0.0/maven-shared-utils-3.0.0.jar
[ERROR] urls[33] = file:/E:/MavenRepository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
[ERROR] urls[34] = file:/E:/MavenRepository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
[ERROR] urls[35] = file:/E:/MavenRepository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
[ERROR] urls[36] = file:/E:/MavenRepository/org/apache/maven/shared/maven-script-interpreter/1.0/maven-script-interpreter-1.0.jar
[ERROR] urls[37] = file:/E:/MavenRepository/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar
[ERROR] urls[38] = file:/E:/MavenRepository/org/apache/ant/ant/1.8.1/ant-1.8.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : org.apache.commons.lang.StringUtils
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
请按任意键继续. . .


  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值