Use Maven to build a Wicket project under NetBeans

Source: Internet
Author: User

Use Maven to build a Wicket project under NetBeans

Building a wicket project in netbeans, a lot of Methods circulating on the Internet are to directly use the netbeans wicket plug-in. Although this method is simple, the dependent wicket version is old and the update is slow, and it is easy to be incompatible with other third-party libraries. Building a wicket project using maven can effectively integrate third-party dependent libraries and use the latest wicket version to reduce security risks. The following describes the methods.

Choose Create Project> Maven> Web Application> next

Next, enter the project name and project location, select next, select the server and Java EE version you are using, and click Finish to create a maven-based web project. Next, add the web dependency project.

After the web Project is created, the pom. xml file is generated in the "project file", open it, find the <dependencies> node, and add the wicket dependency under the node:

<Dependency>
<GroupId> org. apache. wicket </groupId>
<ArtifactId> wicket-core </artifactId>
<Version> 6.22.0 </version>
</Dependency>
<Dependency>
<GroupId> org. apache. wicket </groupId>
<ArtifactId> wicket-auth-roles </artifactId>
<Version> 6.22.0 </version>
</Dependency>
<Dependency>
<GroupId> org. apache. wicket </groupId>
<ArtifactId> wicket-extensions </artifactId>
<Version> 6.22.0 </version>
</Dependency>
<Dependency>
<GroupId> org. apache. wicket </groupId>
<ArtifactId> wicket-ioc </artifactId>
<Version> 6.22.0 </version>
</Dependency>

To add jquery-ui, you can add the following dependencies:

<Dependency>
<GroupId> com. googlecode. wicket-jquery-ui </groupId>
<ArtifactId> wicket-jquery-ui </artifactId>
<Version> 6.22.0 </version> <! -- Or 1.5.11, 6.21.0 -->
</Dependency>
<Dependency>
<GroupId> com. googlecode. wicket-jquery-ui </groupId>
<ArtifactId> wicket-jquery-ui-core </artifactId>
<Version> 6.22.0 </version>
</Dependency>
<Dependency>
<GroupId> com. googlecode. wicket-jquery-ui </groupId>
<ArtifactId> wicket-jquery-ui-calendar </artifactId>
<Version> 6.22.0 </version>
</Dependency>
<Dependency>
<GroupId> com. googlecode. wicket-jquery-ui </groupId>
<ArtifactId> wicket-kendo-ui </artifactId>
<Version> 6.22.0 </version>
</Dependency>

At this time, the dependency is created, and the latest wicket library is also imported. Next, set the code and resource location. Find the <build> node and add a resource node under the node, as shown below:

<Resources>
<Resource>
<Filtering> false </filtering>
<Directory> src/main/java </directory>
<Shortdes>
<Include> ** </include>
</Shortdes>
<Excludes>
<Exclude> **/*. java </exclude>
</Excludes>
</Resource>
</Resources>

Here, the <directory> node specifies the location of the java resource, that is, the location where pom. xml is located as the root directory, and the resource path under it is src/main/java.

Then, you can write the wicket Application code in the resource path. For example, you can define an Application class to inherit from WebApplication and reload some required methods. After wicket code is compiled, modify the web page, delete index. jsp, add a WEB-INF directory, add a web. xml under the directory, copy the following content:

<? Xml version = "1.0" encoding = "UTF-8"?>

<Web-app xmlns = "http://java.sun.com/xml/ns/javaee"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
Version = "3.0">

<Filter>
<Filter-name> WicketApplication </filter-name>
<Filter-class> org. apache. wicket. protocol. http. WicketFilter </filter-class>
<Init-param>
<Param-name> applicationClassName </param-name>
<Param-value> com. example. src. Application </param-value>
</Init-param>
</Filter>

<Filter-mapping>
<Filter-name> WicketApplication </filter-name>
<Url-pattern>/* </url-pattern>
</Filter-mapping>
<Session-config>
<Session-timeout>
30
</Session-timeout>
</Session-config>
</Web-app>
<Param-value> the node corresponds to the name and path of your Application class in src/main/java (com/example/src)

So the wicket project under netbeans is built.

Maven practice: Maven practice tutorial PDF

Use Jenkins to configure Git + Maven for automated building

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.