jetspeed学习笔记1

1.首先下载Maven, http://maven.apache.org/
2.修改Maven相关项,打开Maven安装目录/conf下的setting.xml文件,如下所示:
<localRepository>E:/java/appfuse-repo</localRepository>
<proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username></username>
      <password></password>
      <host>10.3.8.54</host>
      <port>1808</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>

3.建立文件夹,用于存放Jetspeed的项目文件。在dos窗口中进入该文件,执行下列命令(可参考官方网站相关说明 http://portals.apache.org/jetspeed-2/

mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate -DarchetypeGroupId=org.apache.portals.jetspeed-2 -DarchetypeArtifactId=jetspeed-archetype -DarchetypeVersion=2.2.0 -DartifactId=jetexpress -Dpackage=org.apache.portals.tutorials -DgroupId=org.apache.portals.tutorials -Dversion=1.0-SNAPSHOT
4.进入jetexpress项目中,打开文件 jetspeed-mvn-settings.xml进行相关设置,如下所示:
<org.apache.jetspeed.server.home>E:/apache-tomcat-6.0.20/</org.apache.jetspeed.server.home>


<org.apache.jetspeed.production.database.default.name>mysql</org.apache.jetspeed.production.database.default.name>
          <org.apache.jetspeed.production.jdbc.driver.groupId>mysql</org.apache.jetspeed.production.jdbc.driver.groupId>
          <org.apache.jetspeed.production.jdbc.driver.artifactId>mysql-connector-java</org.apache.jetspeed.production.jdbc.driver.artifactId>
          <org.apache.jetspeed.production.jdbc.driver.version>5.1.6</org.apache.jetspeed.production.jdbc.driver.version>
          <org.apache.jetspeed.production.database.driver>com.mysql.jdbc.Driver</org.apache.jetspeed.production.database.driver>
          <org.apache.jetspeed.production.database.url>jdbc:mysql://127.0.0.1:3307/protal</org.apache.jetspeed.production.database.url>
          <org.apache.jetspeed.production.database.user>root</org.apache.jetspeed.production.database.user>
          <org.apache.jetspeed.production.database.password>root</org.apache.jetspeed.production.database.password>


配置Jetspeed的maven插件。打开maven全局配置文件setting.xml(~/.m2/settings.xml on Linux, or %USERPROFILE%\.m2\settings.xml on Windows),做如下配置:
<settings xmlns="http://maven.apache.org/POM/4.0.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
       http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <pluginGroups>
    <pluginGroup>org.apache.portals.jetspeed-2</pluginGroup>
  </pluginGroups>  
  <!-- There might be more configuration here -->     
</settings>

5.执行mvn jetspeed:mvn -Dtarget=all编译命令
6.至此就建立了jetspeed的系统,启动tomcat。
7.问题一:在实际过程遇到了“Failed to retrieve Portlet Definition for jetspeed-layouts::Velocitytwocolumns”,这个是用于tomcat部署项目web.xml/apps/jetspeed-layouts下缺少文件,最终还是由于下载jar包时候出现的问题,解决办法是下载一个覆盖里面的内容即可。问题二:j2-admin组件不能使用,例如普通用户可以登录而管理员用户则不能登录。解决办法换了个新的tomcat
8.自定义一个自己的portlet。首先在dos窗口进入jetexpress项目,使用mvn eclipse:eclipse命令令其项目可以在Eclipse打开,然后把这两项目加入到Eclipse中去。把项目加入后,“In Eclipse, go to Window->Preferences->Java->Build Path->Classpath Variables->New and enter the location of your local Maven repository (typically this is inside a .m2 directory in your user home/profile directory”添加变量。
9.创建一个java类 MyPortlet extends GenericPortlet,重写doHelp、doView和doEdit三个方法,并在相应的 portlet.xml (located in src/main/webapp/WEB-INF)文件中如入:
<portlet>
    <description>Bonjour Monde Portlet</description>    
    <portlet-name>BonjourMonde</portlet-name>  
    <display-name>Bonjour Monde</display-name>
    <portlet-class>org.apache.portals.tutorials.BonjourMonde</portlet-class>          
    <supports>
        <mime-type>text/html</mime-type>
        <portlet-mode>VIEW</portlet-mode>
        <portlet-mode>EDIT</portlet-mode>
        <portlet-mode>HELP</portlet-mode>            
    </supports>
    <supported-locale>en</supported-locale>        
    <portlet-info>
        <title>Bonjour Monde</title>
        <short-title>Bonjour</short-title>
        <keywords>tutorial,bonjour,hello</keywords>
    </portlet-info>
</portlet>

In the jetexpress-portal project, add a folder to the root of our site named src/main/webapp/WEB-INF/pages/tutorial/. In addition to creating the folder, you will need to create a folder.metadata file:

<?xml version="1.0" encoding="UTF-8"?>
<folder>
  <title >Tutorial</title>  
  <metadata name="title" xml:lang="fr">Autodidacte</metadata>
  <security-constraints>
    <security-constraints-ref>public-edit</security-constraints-ref>
  </security-constraints>
</folder>

Then add a new page named default-page.psml under the tutorial directory. Add a portlet window to reference our new portlet:

<?xml version="1.0" encoding="UTF-8"?>
<page>
  <defaults layout-decorator="jetexpress" 
            portlet-decorator="jetexpress"
            skin="jetexpress"/>
  <title>JetExpress Tutorials</title>
  <short-title>Tutorials</short-title>
  <fragment id="tutorial-100" type="layout" name="jetspeed-layouts::VelocityTwoColumns">  
    <fragment id="express-101" type="portlet" name="jetexpress-pa::BonjourMonde"/>
  </fragment>
</page>

Stop Tomcat and deploy your portlet and the new pages:

mvn jetspeed:mvn -Dtarget=deploy-pa
mvn jetspeed:mvn -Dtarget=deploy-portal

你可能感兴趣的:(apache,eclipse,maven,tomcat,mysql)