如何安装 Wicket 框架?

发布于 2024-10-17 08:22:52 字数 27 浏览 4 评论 0 原文

如何安装 Wicket 框架?请指导我!

How can I install the Wicket framework? Please guide me!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

守望孤独 2024-10-24 08:22:52

以下是我几个月前整理的安装 Wicket 的分步说明。它们列出了我在安装了 Eclipse 的普通计算机上设置 Wicket 所做的一切。


  • 下载JDK 6_22
  • 下载Maven 3.01
  • 安装JDK到C:\Program Files\Java\jdk1.6.0_22
  • 解压maven到C:\Program Files\apache-maven-3.0.1

  • 更新的系统环境变量:

    • M2
      C:\Program Files\apache-maven-3.0.1
    • M2_HOME
      %M2_HOME%\bin = C:\Program Files\apache-maven-3.0.1\bin
    • JAVA_HOME
      C:\Program Files\Java\jdk1.6.0_22
    • M2_REPO
      C:\Users\[用户名]\.m2\repository(具体路径将根据您的用户名/Windows 版本而有所不同)

  • 按照 Wicket 快速入门,生成此 Maven 命令:

    mvn 原型:创建
    -DarchetypeGroupId=org.apache.wicket
    -DarchetypeArtifactId=wicket-archetype-quickstart
    -Darchetype版本=1.4.1
    -DgroupId=com.mycompany
    -DartifactId=项目名称
    
  • 从命令行运行上述 Maven 命令

  • 相关文件(包括 Wicket 源代码)是基于 POM 自动下载的。
  • mvn eclipse:eclipse来创建一个基于上述的Eclipse项目
  • 使用File>将项目导入到Eclipse中导入...,现有项目

  • 在测试文件夹中运行Start.java,并发现测试应用程序已在http://localhost:8080启动并运行code>

可选:支持对于第三方代码,例如 Wicket Extensions
手动将 Wicket Extensions JAR 文件添加到 M2_REPO 目录将不起作用。

相反,请在更新 POM 后运行 mvn clean dependency:copy-dependencies。 (Wicket Extensions 包含在内,但在默认 POM 中被注释掉。)然后使用 Add Variables... (不是 Add JARs)在 Eclipse 中配置构建路径,选择 < code>M2_REPO,按Extend,找到所需的 JAR(在本例中为 Wicket Extensions)。

类似的过程应该适用于其他第三方库。


我原本打算继续更新此网页以提供更多说明,但是我最近一直在做其他事情。 不过,最终,我希望能够了解如何使用 Tomcat 配置 Wicket,而不是仅仅依赖它附带的 jetty 服务器。

更新

部署到 Tomcat 的说明如下:

  • 下载并安装 Apache TomcatApache Ant

  • 创建以下目录结构:

    <前><代码>\WicketTomcat
    +---源代码
    | +---主要
    | | +---java
    | | | \---com
    | | | \---HelloWicket
    | | | HelloWorld.java
    | | | HelloWorld.html
    | | | HelloWorldApplication.java
    | | \---网络应用程序
    | | \---WEB-INF
    | |网络.xml
    | \ - -测试
    | \---java
    +---库
    | junit.jar
    | log4j.jar
    | servlet-api.jar
    | slf4j-api.jar
    | slf4j-log4j.jar
    | wicket.jar
    | wicket-extensions.jar
    +---目标
    构建.xml

  • 填写文件如下:

HelloWorld.java

package com.HelloWicket;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;

public class HelloWorld extends WebPage {
    public HelloWorld() {
        add(new Label("message", "Hello, Wicket!"));
    }
}

HelloWorld.java html

<html>
<head>
<title>Wicket Tomcat test title</title>
</head>
<body>
    <span wicket:id="message">Message goes here</span>
</body>
</html>

HelloWorldApplication.java

package com.HelloWicket;

import org.apache.wicket.Page;
import org.apache.wicket.protocol.http.WebApplication;

public class HelloWorldApplication extends WebApplication {
    public HelloWorldApplication() {
    }

    /**
     * @see org.apache.wicket.Application#getHomePage()
     */
    @Override
    public Class<? extends Page> getHomePage() {
        return HelloWorld.class;
    }
}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <display-name>Extremely simple example of deploying Wicket on Tomcat</display-name>
    <context-param>
        <param-name>configuration</param-name>
        <param-value>development</param-value> <!-- Wicket mode (development or deployment) -->
    </context-param>
    <filter>
        <filter-name>HelloWicket</filter-name> <!-- To be used in filter-mapping > filter-name below -->
        <filter-class>
            org.apache.wicket.protocol.http.WicketFilter
        </filter-class>
        <init-param>
            <param-name>applicationClassName</param-name>
            <param-value>
                com.HelloWicket.HelloWorldApplication <!-- Fully qualified name of WebApplication class -->
            </param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>HelloWicket</filter-name> <!-- Must match filter > filter-name above -->
        <url-pattern>/*</url-pattern> <!-- Take control of all URLs that start with http://localhost:8080/HelloWicket/  -->
    </filter-mapping>
</web-app>

<!--
After deploying to Tomcat, access with http://localhost:8080/HelloWicket/.

Source: http://wicket.apache.org/learn/examples/helloworld.html
-->

build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project default="war" name="HelloWicket" basedir=".">
    <property name="final.name" value="HelloWicket" />
    <property name="src.main.dir" value="src/main/java" />
    <property name="src.test.dir" value="src/test/java" />
    <property name="src.web.dir" value="src/main/webapp" />
    <property name="lib.dir" value="lib" />
    <property name="build.dir" value="target" />
    <property name="build.main.classes" value="${build.dir}/classes" />
    <property name="build.test.classes" value="${build.dir}/test-classes" />
    <property name="build.test.reports" value="${build.dir}/test-reports" />
    <property name="build.reports.dir" value="${build.dir}/reports" />
    <property name="tomcat.dir" value="..\..\..\..\Program Files\Apache Software Foundation\apache-tomcat-7.0.22\webapps" />

    <path id="build.classpath">
        <fileset dir="${lib.dir}">
            <include name="**/*.jar" />
        </fileset>
    </path>
    <target name="clean">
        <delete dir="${build.dir}" failonerror="false" />
        <delete file="${final.name}.war" failonerror="false" />
    </target>
    <target name="init">
        <mkdir dir="${build.dir}" />
    </target>
    <target name="compile" depends="init">
        <mkdir dir="${build.main.classes}" />
        <javac destdir="${build.main.classes}" target="1.6" source="1.6" srcdir="${src.main.dir}" classpathref="build.classpath" includeantruntime="false" />
        <copy todir="${build.main.classes}">
            <fileset dir="${src.main.dir}">
                <include name="**/*.*" />
                <exclude name="**/*.java" />
            </fileset>
        </copy>
    </target>
    <target name="test-compile" depends="compile">
        <mkdir dir="${build.test.classes}" />
        <javac destdir="${build.test.classes}" target="1.6" source="1.6" srcdir="${src.test.dir}" includeantruntime="false">
            <classpath>
                <path refid="build.classpath" />
                <pathelement path="${build.main.classes}" />
            </classpath>
        </javac>
        <copy todir="${build.test.classes}">
            <fileset dir="${src.test.dir}">
                <include name="**/*.*" />
                <exclude name="**/*.java" />
            </fileset>
        </copy>
    </target>
    <target name="test" depends="test-compile">
        <mkdir dir="${build.test.reports}" />
        <junit dir="./" failureproperty="test.failure" printSummary="yes" fork="true" haltonerror="true">
            <sysproperty key="basedir" value="." />
            <formatter type="xml" />
            <classpath>
                <path refid="build.classpath" />
                <pathelement path="${build.main.classes}" />
                <pathelement path="${build.test.classes}" />
            </classpath>
            <batchtest todir="${build.test.reports}">
                <fileset dir="${src.test.dir}">
                    <include name="**/*Test*.java" />
                </fileset>
            </batchtest>
        </junit>
        <mkdir dir="${build.reports.dir}" />
        <junitreport todir="${build.reports.dir}">
            <fileset dir="${build.test.reports}">
                <include name="TEST-*.xml" />
            </fileset>
            <report format="frames" todir="${build.reports.dir}" />
        </junitreport>
    </target>
    <target name="war" depends="test">
        <war destfile="${build.dir}/${final.name}.war" webxml="${src.web.dir}/WEB-INF/web.xml">
            <lib dir="lib">
                <include name="wicket*.jar" />
                <include name="slf4j*.jar" />
                <include name="log4j*.jar" />
                <include name="servlet*.jar" />
            </lib>
            <classes dir="${build.main.classes}" />
            <fileset dir="${src.web.dir}">
                <include name="**/*" />
                <exclude name="**/web.xml" />
            </fileset>
        </war>
    </target>

    <target name="deploy" depends="war">
        <echo>Deploying .war to local Tomcat</echo>
        <copy todir="${tomcat.dir}">
            <fileset dir="${build.dir}" includes="${final.name}.war" />
        </copy>
    </target>
</project>

正如我对原始答案所做的那样,我发布了一个稍微更具解释性的版本这个答案这里,但这应该足以让你继续前进。

Here are step-by-step instructions I put together a few months ago for installing Wicket. They list everything I did to set Wicket up on a vanilla machine with Eclipse installed.


  • Downloaded JDK 6_22
  • Downloaded Maven 3.01
  • Installed JDK to C:\Program Files\Java\jdk1.6.0_22
  • Unzipped maven to C:\Program Files\apache-maven-3.0.1

  • Updated system environment variables:

    • M2
      C:\Program Files\apache-maven-3.0.1
    • M2_HOME
      %M2_HOME%\bin = C:\Program Files\apache-maven-3.0.1\bin
    • JAVA_HOME
      C:\Program Files\Java\jdk1.6.0_22
    • M2_REPO
      C:\Users\[username]\.m2\repository (exact path will vary based on your username/Windows version)

  • Followed instructions at Wicket quickstart, generating this Maven command:

    mvn archetype:create
    -DarchetypeGroupId=org.apache.wicket
    -DarchetypeArtifactId=wicket-archetype-quickstart
    -DarchetypeVersion=1.4.1
    -DgroupId=com.mycompany
    -DartifactId=projName
    
  • Ran above Maven command from command line

  • Relevant files, including Wicket source, were downloaded automatically, based on POM.
  • Ran mvn eclipse:eclipse to create an Eclipse project based on above
  • Imported project into Eclipse with File > Import..., Existing Projects

  • Ran Start.java in the test folder and found the test app up and running at http://localhost:8080

Optional: support for third-party code, like Wicket Extensions
Manually adding the Wicket Extensions JAR file to to the M2_REPO directory won't work.

Instead, run mvn clean dependency:copy-dependencies after updating the POM. (Wicket Extensions is included but commented out in the default POM.) Then configure the build path in Eclipse by using Add Variables... (not Add JARs), select M2_REPO, press Extend, find the desired JAR (in this case, Wicket Extensions).

A similar procedure should work for other third-party libraries.


I was originally going to keep updating this web page with more instructions, but I've been working on other things lately. Eventually, though, I hope to get around to instructions on how to configure Wicket with Tomcat instead of relying solely on the jetty server it comes with.

UPDATE

Instructions for deploying to Tomcat are here:

  • Download and install Apache Tomcat and Apache Ant.

  • Create the following directory structure:

    \WicketTomcat
      +---src
      | +---main
      | | +---java
      | | | \---com
      | | |   \---HelloWicket
      | | |         HelloWorld.java
      | | |         HelloWorld.html
      | | |         HelloWorldApplication.java
      | | \---webapp
      | |   \---WEB-INF
      | |         web.xml
      | \---test
      |   \---java
      +---lib
      |     junit.jar
      |     log4j.jar
      |     servlet-api.jar
      |     slf4j-api.jar
      |     slf4j-log4j.jar
      |     wicket.jar
      |     wicket-extensions.jar
      +---target
        build.xml
    
  • Fill in the files as follows:

HelloWorld.java

package com.HelloWicket;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;

public class HelloWorld extends WebPage {
    public HelloWorld() {
        add(new Label("message", "Hello, Wicket!"));
    }
}

HelloWorld.html

<html>
<head>
<title>Wicket Tomcat test title</title>
</head>
<body>
    <span wicket:id="message">Message goes here</span>
</body>
</html>

HelloWorldApplication.java

package com.HelloWicket;

import org.apache.wicket.Page;
import org.apache.wicket.protocol.http.WebApplication;

public class HelloWorldApplication extends WebApplication {
    public HelloWorldApplication() {
    }

    /**
     * @see org.apache.wicket.Application#getHomePage()
     */
    @Override
    public Class<? extends Page> getHomePage() {
        return HelloWorld.class;
    }
}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <display-name>Extremely simple example of deploying Wicket on Tomcat</display-name>
    <context-param>
        <param-name>configuration</param-name>
        <param-value>development</param-value> <!-- Wicket mode (development or deployment) -->
    </context-param>
    <filter>
        <filter-name>HelloWicket</filter-name> <!-- To be used in filter-mapping > filter-name below -->
        <filter-class>
            org.apache.wicket.protocol.http.WicketFilter
        </filter-class>
        <init-param>
            <param-name>applicationClassName</param-name>
            <param-value>
                com.HelloWicket.HelloWorldApplication <!-- Fully qualified name of WebApplication class -->
            </param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>HelloWicket</filter-name> <!-- Must match filter > filter-name above -->
        <url-pattern>/*</url-pattern> <!-- Take control of all URLs that start with http://localhost:8080/HelloWicket/  -->
    </filter-mapping>
</web-app>

<!--
After deploying to Tomcat, access with http://localhost:8080/HelloWicket/.

Source: http://wicket.apache.org/learn/examples/helloworld.html
-->

build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project default="war" name="HelloWicket" basedir=".">
    <property name="final.name" value="HelloWicket" />
    <property name="src.main.dir" value="src/main/java" />
    <property name="src.test.dir" value="src/test/java" />
    <property name="src.web.dir" value="src/main/webapp" />
    <property name="lib.dir" value="lib" />
    <property name="build.dir" value="target" />
    <property name="build.main.classes" value="${build.dir}/classes" />
    <property name="build.test.classes" value="${build.dir}/test-classes" />
    <property name="build.test.reports" value="${build.dir}/test-reports" />
    <property name="build.reports.dir" value="${build.dir}/reports" />
    <property name="tomcat.dir" value="..\..\..\..\Program Files\Apache Software Foundation\apache-tomcat-7.0.22\webapps" />

    <path id="build.classpath">
        <fileset dir="${lib.dir}">
            <include name="**/*.jar" />
        </fileset>
    </path>
    <target name="clean">
        <delete dir="${build.dir}" failonerror="false" />
        <delete file="${final.name}.war" failonerror="false" />
    </target>
    <target name="init">
        <mkdir dir="${build.dir}" />
    </target>
    <target name="compile" depends="init">
        <mkdir dir="${build.main.classes}" />
        <javac destdir="${build.main.classes}" target="1.6" source="1.6" srcdir="${src.main.dir}" classpathref="build.classpath" includeantruntime="false" />
        <copy todir="${build.main.classes}">
            <fileset dir="${src.main.dir}">
                <include name="**/*.*" />
                <exclude name="**/*.java" />
            </fileset>
        </copy>
    </target>
    <target name="test-compile" depends="compile">
        <mkdir dir="${build.test.classes}" />
        <javac destdir="${build.test.classes}" target="1.6" source="1.6" srcdir="${src.test.dir}" includeantruntime="false">
            <classpath>
                <path refid="build.classpath" />
                <pathelement path="${build.main.classes}" />
            </classpath>
        </javac>
        <copy todir="${build.test.classes}">
            <fileset dir="${src.test.dir}">
                <include name="**/*.*" />
                <exclude name="**/*.java" />
            </fileset>
        </copy>
    </target>
    <target name="test" depends="test-compile">
        <mkdir dir="${build.test.reports}" />
        <junit dir="./" failureproperty="test.failure" printSummary="yes" fork="true" haltonerror="true">
            <sysproperty key="basedir" value="." />
            <formatter type="xml" />
            <classpath>
                <path refid="build.classpath" />
                <pathelement path="${build.main.classes}" />
                <pathelement path="${build.test.classes}" />
            </classpath>
            <batchtest todir="${build.test.reports}">
                <fileset dir="${src.test.dir}">
                    <include name="**/*Test*.java" />
                </fileset>
            </batchtest>
        </junit>
        <mkdir dir="${build.reports.dir}" />
        <junitreport todir="${build.reports.dir}">
            <fileset dir="${build.test.reports}">
                <include name="TEST-*.xml" />
            </fileset>
            <report format="frames" todir="${build.reports.dir}" />
        </junitreport>
    </target>
    <target name="war" depends="test">
        <war destfile="${build.dir}/${final.name}.war" webxml="${src.web.dir}/WEB-INF/web.xml">
            <lib dir="lib">
                <include name="wicket*.jar" />
                <include name="slf4j*.jar" />
                <include name="log4j*.jar" />
                <include name="servlet*.jar" />
            </lib>
            <classes dir="${build.main.classes}" />
            <fileset dir="${src.web.dir}">
                <include name="**/*" />
                <exclude name="**/web.xml" />
            </fileset>
        </war>
    </target>

    <target name="deploy" depends="war">
        <echo>Deploying .war to local Tomcat</echo>
        <copy todir="${tomcat.dir}">
            <fileset dir="${build.dir}" includes="${final.name}.war" />
        </copy>
    </target>
</project>

As I did with the original answer, I posted a slightly more explanatory version of this answer here, but this should really be enough to get you going.

输什么也不输骨气 2024-10-24 08:22:52

确保已安装 maven2,然后转到 http://wicket.apache.org/start/quickstart .html,从那里复制命令行并运行它。这应该创建一个包含演示应用程序和页面的项目,您可以将其导入到您最喜欢的 IDE 中并使用。

Make sure you have maven2 installed, then go to http://wicket.apache.org/start/quickstart.html, copy the command line from there and run it. That should create a project with a demo application and page that you can import in your favourite IDE and play with.

一片旧的回忆 2024-10-24 08:22:52

http://wicket.apache.org/start/quickstart.html

以下是创建 Wicket 快速入门的一些信息项目。

http://wicket.apache.org/start/quickstart.html

Here is some information for creating a Wicket quickstart project.

没有伤那来痛 2024-10-24 08:22:52

如果您想将 wicket 与其他框架(Spring、JPA、Hibernate、Guice...)一起使用,您可以在此页面生成示例 Maven 命令: http://www.jweekend.com/dev/LegUp

对于每个原型,您都将获得一个具有简单功能的示例项目,可以用作进一步开发的基础。

If you want to use wicket together with other frameworks (Spring, JPA, Hibernate, Guice,...) you can generate sample maven commands at this page: http://www.jweekend.com/dev/LegUp

For every archetype you will get a sample project with simple functionality which can be used as base for your further development.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文