热门文章 | 热门软件| 热门源码 | 热门电影 | 知识库 | 联系我们
软件 源码 教程 影视 健康 招聘
  HTML | JavaScript | ASP | PHP | JSP | NET | VB | VC | VF | Windows | Linux | Mysql | Mssql | Oracle | Struts 
当前位置: 创世纪计算机资源网 -> 文章频道 ->struts 
站内搜索:
经典的Struts2+Spring 2+JPA+AJAX学习项目(1)
作者:佚名 来源:互联网 整理日期:2008-4-9

Tomcat

Install Tomcat before going forward. See Tomcats installation guide if you have any problem installing it.

MySql

Install and configure MySql. Create a database named "quickstart" and run the script below to create the "Person" table. Later, on applicationContext.xml, well use root as the user name and password for the database, remember to replace those values with the right ones for your database.

CREATE TABLE quickstart.Person (
  id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  firstName VARCHAR(45) NOT NULL,
  lastName VARCHAR(45) NOT NULL,
  PRIMARY KEY(id)
)
ENGINE = InnoDB;

Get the code

Show me the code

You can just download the zipped Eclipse project, add the required dependencies to the lib folder under the /WebContent/WEB-INF/lib folder (relative to projects root folder) and import it into Eclipse.

The maven way

To run the project this way you will need maven installed.

  1. Download the zipped project
  2. Download jta jar from here.
    • Note that the Download Manager may save the file to your root drive, and it may give the file a .ZIP extension. You must rename the file to jta-1.1-classes.jar.
    • If a later version is available, update the version references in the next step.
  3. Install the jta jar file running:
    java>$ mvn install:install-file -DgroupId=javax.transaction 
    -DartifactId=jta -Dversion=1.1 -Dpackaging=jar -Dfile=
    c:\path\to\jar\jta-1.1-classes.jar
  4. Bear with me, we are almost there
  5. cd into quickstart and run:
    java>$ mvn jetty:run
  6. Point your browser to http://localhost:8080/quickstart
  7. To create an eclipse project run:
    java>$ mvn eclipse:eclipse

    or (to create web project for WTP):

    java>mvn eclipse:eclipse -Dwtpversion=1.0

Doing it yourself

Create Eclipse project

  1. Open Eclipse. Seriously, you need to open Eclipse.
  2. Click File -> New -> Project. Under the "Web" folder, select "Dynamic Web Project" and click "Next".
  3. Enter the project name, "quickstart" from here on. The project will be running inside Tomcat, so we need to create a server configuration for it.
    1. Under "Target Runtime", click "New", select "Apache Tomcat 5.5" and click next.
    2. Enter Tomcats installation directory and select an installed JRE (1.5 is required)
  4. Now you should be back to the project creation wizard, with Tomcat as your Target Runtime. Click "Next". Select "Dynamic Web Module" and "Java" facets, and click "Finish".

Dependencies

Your project should contain the folders "src", "build" and "WebContent". We are going to put all the required jars under "/WebContent/WEB-INF/lib". To add files to the "lib" folder, just copy them to ${workspace}\quickstart\WebContent\WEB-INF\lib, where ${workspace} is the location of your Eclipse workspace folder.

In the table, the version has been removed from the JAR files, since these may change in future milestone releases. Use whatever version is shipping with the indicated products.

JAR From License
xwork.jar Struts 2 Apache License
struts2-core.jar Struts 2
struts2-spring-plugin.jar Struts 2
ognl.jar Struts 2
freemarker.jar Struts 2
commons-logging-api.jar Struts 2
mysql-connector-java.jar MySql JDBC Driver MySQL licensing policy
spring.jar Spring 2.0 Apache License
antlr.jar Hibernate Core LGPL
asm.jar Hibernate Core
asm-attrs.jar Hibernate Core
cglib.jar Hibernate Core
dom4j.jar Hibernate Core
jdbc2_0-stdext.jar Hibernate Core
ehcache.jar Hibernate Core
hibernate3.jar Hibernate Core
xml-apis.jar Hibernate Core
commons-collections.jar Hibernate Core
ejb3-persistence.jar Hibernate Annotations LGPL
jta.jar Hibernate Annotations
hibernate-commons-annotations.jar Hibernate Annotations
hibernate-annotations.jar Hibernate Annotations
hibernate-entitymanager.jar Hibernate Entity Manager LGPL
javassist.jar Hibernate Entity Manager
jboss-archive-browsing.jar Hibernate Entity Manager

[1]  [2]  [3]  [4]  [5]  
相关文章