如何将gerrit如何提交代码放入tomcat

Git+Gerrit+Gradle+Jenkins持续集成 | OpenWares | Open Source and Free Matters
Copyleft &
本站为原创网站,除非另有声明,本网站采用授权.Java Deployment with Gerrit, Jenkins and Sonar
This tutorial show how to configure a pretested commit scenario for a Java project using the Git, Gerrit and Jenkins open source tools.
It showns how to create a Git repository at Github, then create and configure a repository in Gerrit and how to configure a Jenkins job to listen to changes in the Gerrit code review. A simple Java project is created using Maven and Eclipse, the changes are pushed to Gerrit. Gerrit triggers builds at Jenkins and Jenkins reports back to Gerrit with the results. Additionally Jenkins runs Sonar analysis for every commit a developers make. That way every commit is tested separately allowing for a fine-grained quality control.
Tools referenced:
* Jenkins:
* SonarQube:
Related Posts:
Software Development KnowledgeDeveloping Web applications with Tomcat and Eclipse
componentsThe Eclipse V3.2 Callisto integrated development environment (IDE) includes
tools for doing Web development and integrating with servers. So, aside
from the software development kit (SDK), you need only Eclipse and Apache
Tomcat installed. The versions featured in this article are listed
below.Table 1. Components and versions usedComponentVersion used in this article3.2.21.5.0_095.5.20The Eclipse IDE is an open source IDE used as the development environment
for your JavaServer Pages (JSPs) and Java files. With the Web and Java 2
Platform, Enterprise Edition (J2EE) Development tools installed, Eclipse
is great tool for creating HTML, JSPs, and servlets.You need the Java SDK to run servlets on your machine. Finally, Apache
Tomcat is an open source Web and servlet container, used in the official
reference implementations for Java Servlet and Java Server Pages.InstallationInstallation of Eclipse and Tomcat is similar — both are extracted
from the archive file format into a folder on your hard disk. If you ever
want to uninstall either, it's as simple as deleting the directory in
which you extracted the files.Install EclipseTo install the Eclipse IDE, unpack the compressed (.zip or .tar.gz) file
you downloaded from Eclipse, then move the unpacked folder into a
convenient location. I try to install it in a location that follows the
conventions of whatever operating system I'm using. If I'm installing
Eclipse on a Macintosh, I put the Eclipse folder in the Applications
folder. If I'm using Microsoft® Windows®, I put the unpacked
folder into the C:\Program Files directory.Once you've downloaded and installed Eclipse, start it up. Before you can
create a Web project, you need to install the J2EE and Web Development
plug-ins. Fortunately, it's easy to install the plug-in using the Callisto
Discovery Site.Install the Web
toolsWith the Eclipse IDE running, select Help & Software Updates
& Find and Install. This option lets you download and
install the Web tools without going to a Web site.Select Search for New Features to Install, as shown below,
then click Next.Figure 1. Install/Update windowSelect Callisto Discovery Site, as shown below, then click
Next.Figure 2. Select the Callisto Discovery SiteUnder Callisto Discovery Site, check the Web and
J2EE Development box. The wizard immediately warns you that
you're missing dependencies. Click Select Required, and
these warnings should disappear. Some or all of the components in the
Graphical Editors and Frameworks and Models and Model Development
categories are selected (as shown in Figure 3) because they're required
for the installation of the Web and J2EE plug-ins.Figure 3. Select features for installationClick Next to continue, and license agreements appear for
each feature you've selected. If you agree with the licenses, accept them
and follow the wizard through the rest of the process. When the IDE is
finished installing the plug-ins, it asks you to restart Eclipse in order
for the changes to take effect. Be sure you restart the IDE before
continuing.After you restart the IDE, the new features are available to begin
developing dynamic Web projects.Install
TomcatTo install Apache Tomcat, extract the files from the downloaded archive and
place them into a directory. I put them in my C:\apps directory to make
them easy to locate later. That' use Eclipse as shown later
to start Tomcat.Create a new Web
projectFrom the Eclipse IDE, select File & New & Project to
view the project wizards. Type Web in the Wizards box, and
the New Project window filters the wizards to show the ones that match.
This is an easy way to locate the wizard you want instead of going through
each item.Choose Dynamic Web Project from the list. You use the
Standard Web Project Wizard to make static HTML Web projects. You can
technically use Tomcat to run static Web sites, although a Web server such
as Apache Web Server may be a better choice for static content. Web
servers built specifically for serving up static pages tend to have less
overhead and are tuned for that purpose.Target a
runtimeUnder Target Runtime, you see &None&, as shown in
Figure 4, because you haven't created a runtime yet for Apache Tomcat.
Click New to open the New Target Runtime
Wizard. Select Apache Tomcat V5.5 from the Apache folder, as
shown in Figure 5, then click Next.Figure 4. Create a new dynamic Web projectFigure 5. Create a new server runtimeNow you have the opportunity to name your runtime, although the default
name Apache Tomcat V5.5 is fine. Click Browse to locate
the base folder for your Apache Tomcat configuration (mine is
C:\apps\apache-tomcat-5.5.20, as shown in Figure 6). I recommend leaving
the IBM® Java Runtime Environment (JRE) version the same as the
workbench default JRE, unless you have a specific reason to change it.
Once you've entered a valid directory, click Finish to
create the runtime configuration.Figure 6. Define the server locationYou're asked if you want to switch to the J2EE Perspective. I always answer
yes because that perspective includes views like the Servers view, which
help to start and stop Tomcat later. You can always open the Servers view
by selecting Window & Show View.Add the
serverIn the Servers view is a view that contains nothing. This view is for
application and W it lets you control them and monitor their
status. To control Tomcat directly from the comfort of the IDE, add a
reference to Tomcat by selecting New & Server from the
context-sensitive menu. The New Server wizard, as shown
in Figure 7, will default to the Apache Tomcat V5.5 runtime you just
created.Figure 7. Define a new serverClick Next. You're asked whether you want to add projects
to the server. Select the project you created in the previous steps, then
click Add.Figure 8. Add the projects to the serverClick Finish to close the wizard. Now the Servers view
contains the Tomcat V5.5 Server with the project under it.Figure 9. The Tomcat server in the Servers
viewCreate a sample
pageThe easiest way to test your new dynamic Web project and Tomcat server
integration is to create a simple JSP and deploy it to Tomcat. You can
create the new JSP file by selecting File & New &
Other, or you can use the context-sensitive menu by
right-clicking the project name in the Project Explorer view and selecting
New & JSP.Make sure the parent folder is WebContent and name the file index.jsp.
Click Finish to create the page using the default
template. If you click Next, you can choose different
templates to use (such as HTML or XHTML) for the new page. The defaults
are fine for this test.The page code shown below displays a simple date so you can see it
working.Listing 1. Contents of
index.jsp&%@ page language="java" contentType="text/ charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%&
&!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"&
&meta http-equiv="Content-Type" content="text/ charset=ISO-8859-1"&
&title&My Title&/title&
&% java.util.Date d = new java.util.Date(); %&
Today's date is &%= d.toString() %& and this jsp page worked!
&/html&Deploy the
pageNow that the test page is complete, use Eclipse to redeploy it to Apache
Tomcat. In the Servers view, notice that State is set to Republish. That
is because changes have been made since the project was last deployed to
the server. Right-click the server and select Publish
from the menu. The state changes to Synchronized once the project has been
deployed to the server.With the project successfully deployed and the server started, open a
browser and navigate to http://localhost:8080/[ProjectName]/ (where
[ProjectName] is the name of the dynamic Web project you created). The new
Web page you created appears, and the date should be current. If you
refresh the page, the date changes.Figure 10. Output of index.jsp in a browserHello World
servletYou can add Java servlets to your project and deploy them. To create a
quick servlet you can use for testing purposes, use the Servlet Wizard by
right-clicking your dynamic Web project in the Project Explorer view and
selecting New & Other. Under the Web folder, select
Servlet, then click Next.Add the package name com.example.servlets next to Java
Package and add HelloServlet next to
Class name. Click Finish. This is an
example, so the defaults are fine. The Eclipse IDE generates a servlet
class for you. To watch the test servlet in action, add a line in the
doGet() method to print a message to the ResponseWriter. The
servlet class should look like the one shown below.Listing 2. Contents of
HelloServlet.javapackage com.example.
import java.io.IOE
import javax.servlet.ServletE
import javax.servlet.http.HttpServletR
import javax.servlet.http.HttpServletR
* Servlet implementation class for Servlet: HelloServlet
public class HelloServlet extends javax.servlet.http.HttpServlet
implements javax.servlet.Servlet {
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
public HelloServlet() {
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.getWriter().write("Hello, world!");
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
}After you add the servlet, the Eclipse IDE notes that your project has
changed. Look again at the S Restart now appears in the Status
column next to the Tomcat server. To restart the server, right-click the
server in the Servers view, then select Restart &
Start. Open a browser and navigate to
http://localhost:8080/[ProjectName]/HelloServlet (where [ProjectName] is
the name of your dynamic Web project). The text "Hello, world!" appears in
the browser window. You can add the date, similar to the code in the
index.jsp file, to the doGet() method, and redeploy the
servlet using the Eclipse IDE.SummaryIt's productive to develop JSPs and servlets without having to leave the
IDE to start, stop, or deploy to your server. The combination of Eclipse
and Apache Tomcat provides an easy integrated environment that enables you
to speed up development.
Related topics
to add and subscribe to comments.
Subscribe me to comment notifications
static.content.url=/developerworks/js/artrating/SITE_ID=1Zone=Open sourceArticleID=217033ArticleTitle=Developing Web applications with Tomcat and Eclipsepublish-date=
Newsletters
dW PremiumGmane -- Mail To News And Back Again
Statistics
From: Shawn Pearce &sop &at& &
Newsgroups:
Date: Friday 13th December :32 UTC (over 2 years ago)
On Thu, Dec 12, 2013 at 7:45 AM, Darin Ramdhanie
> I recently installed Gerrit-2.8 with Tomcat and MySql. The application
> installed without any errors however when i access the application i am
> and Error - 500 Internal Server Error.
From investigating the tomcat log
> am seeing mysql syntax error OPTION SQL_SELECT_LIMIT=26 i think there was
> some deprecation of the mysql syntax.
The MySQL JDBC driver you installed is not compatible with the MySQL
server version you installed. You need to find a pair that works}

我要回帖

更多关于 gerrit 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信