基于hybris-commerce-suite-5.4.0.0,独立安装hybris-oms组件,开发环境为Ubuntu14
1、修改setting.xml文件
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 <settings xmlns="http://maven.apache.org/settings/1.0.0" 2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> 4 5 <localRepository>/home/luoyq/work/repository</localRepository> 6 7 <pluginGroups> 8 <pluginGroup>de.hybris.mavenplugins</pluginGroup> 9 <pluginGroup>org.codehaus.cargo</pluginGroup> 10 <pluginGroup>de.hybris.platform</pluginGroup> 11 </pluginGroups> 12 <servers> 13 </servers> 14 <profiles> 15 <profile> 16 <id>defaultProfile</id> 17 <activation> 18 <activeByDefault>true</activeByDefault> 19 </activation> 20 <repositories> 21 <repository> 22 <id>hybris-local</id> 23 <url>file:///home/luoyq/work/hybris-commerce-suite-5.4.0.0/hybris-dependencies</url> 24 <snapshots> 25 <enabled>true</enabled> 26 <updatePolicy>daily</updatePolicy> 27 <checksumPolicy>warn</checksumPolicy> 28 </snapshots> 29 </repository> 30 <repository> 31 <id>maven2</id> 32 <url>http://repo.maven.apache.org/maven2</url> 33 </repository> 34 </repositories> 35 <pluginRepositories> 36 <pluginRepository> 37 <id>maven2</id> 38 <url>http://repo.maven.apache.org/maven2</url> 39 </pluginRepository> 40 <pluginRepository> 41 <id>hybris-local</id> 42 <url>file:///home/luoyq/work/hybris-commerce-suite-5.4.0.0/hybris-dependencies</url> 43 <snapshots> 44 <enabled>true</enabled> 45 <updatePolicy>daily</updatePolicy> 46 <checksumPolicy>warn</checksumPolicy> 47 </snapshots> 48 </pluginRepository> 49 </pluginRepositories> 50 </profile> 51 </profiles> 52 </settings>
2、安装oracle-jdbc 驱动,下载地址: www.oracle.com
$cd ~/下载
$mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -Dpackaging=jar -Dfile=ojdbc6-11.2.0.4.jar -DgeneratePom=true
3、编译 archetype SDK
解压hybris-commerce-suite-5.4.0.0.zip,进入archetype文件夹并执行 maven install
$ cd hybris-commerce-suite-5.4.0.0/hybris-oms/sdk/archetype/
$ maven install
问题1 : https://maven.alfresco.com/nexus/content/groups/public/ 部分依赖无法下载
解决:注释<repositories></repositories>
$cd ~/work/hybris-commerce-suite-5.4.0.0/hybris-oms/sdk/archetype/src/main/resources/archetype-resources/__rootArtifactId__-service
$vi pom.xml
问题2:test失败
解决:忽略测试
$ mvn clean install -Dmaven.test.skip=true
4、创建oms 扩展项目
$mkdir hybris-oms-trail
$cd hybris-oms-trail
$ mvn archetype:generate -DarchetypeGroupId=com.hybris.oms.ext -DarchetypeArtifactId=oms-ext-archetype -DarchetypeVersion=5.4.0.11
groupId: org.training.oms
artifactId: oms-ext
version: 1.0-SNAPSHOT
package: org.training.oms
artifactId: oms-ext
version: 1.0-SNAPSHOT
package: org.training.oms
编译maven项目,导入eclipse
$cd ~/work/hybris-oms-trail/oms-ext
$maven clean package -Dmaven.test.skip=true
执行上面命令后,会在oms-ext-api、oms-ext-service 的target目录下生成 generated-sources ,copy到 src/main/java下,解决eclipse的编译错误
5、修改配置文件,启动oms-ext-web应用
oms-ext\oms-ext-service\src\main\resources\local.properties ,修改mysql相关配置
oms-ext\oms-ext-web\src\main\resources\logback.xml,修改日志配置
在oms-ext-web\pom.xml中增加 mysql驱动依赖
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
问题 :执行mvn clean package -Dmaven.test.skip=true时报重复类的错误
解决: 注释 oms-ext-api\oms-ext-service 的 pom.xml 中的generate-sources插件
6、修改tomcat配置文件,设置虚拟目录
win7 : catalina.bat
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
set "JAVA_OPTS=-Xms1g -Xmx1g -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=512m"
Linux : catalina.sh
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
JAVA_OPTS="-Xms2g -Xmx2g -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=512m"
虚拟目录下设置,修改 conf/server.conf,增加
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
<Context path="/oms-ext-web" reloadable="true" docBase="/home/luoyq/work/hybris-oms-trail/oms-ext/oms-ext-web/target/oms-ext-web-1.0-SNAPSHOT"/>
7、测试
启动后访问http://localhost:8080/oms-ext-web/init-app-web/console/main 进行初始化
在FireFox附加组件中搜索安装 HttpRequester ,重启FireFox后,打开HttpRequester
发送 Get 请求
http://localhost:8080/oms-ext-web/webresources/stockrooms ,注意要在 Header中add 参数
X-tenantId,值为 single
请求返回的结果为一段xml