此处声明 ,关于sshpermissions 开源项目本人没有参与,在此把此开源项目的基本环境搭建和大家共享一下,如有侵权,请跟帖说明。感谢sshpermissions的作者对开源项目的无私贡献。
在此简单说明一下sshpermissions:此项目主要使用shiro作为权限管理框架,同时使用了jbpm工作流等框架,对于想学习这两方面知识的同学应该有帮助。
此处附上sshpermissions的地址:
http://code.google.com/p/sshpermissions/
关于sshpermissions的源码下载请参考文:
http://www.cnblogs.com/skyme/archive/2012/08/15/2639433.html
这里我遇到的问题是:在eclipse中无法检出,所以我用的是Windows下的SVN管理工具:TortoiseSVN
安装TortoiseSVN完毕,直接在任意一个文件夹中右键选择SVN CheckOut ,填入地址:
http://sshpermissions.googlecode.com/svn/trunk
检出完毕应该有以下文件:sshpermissions 中包含 sshpermission、tgBase、tgTemplateEngine、tgTree
等源码包
环境准备:eclipse 中的tomcat 配置如图:
注意Server Options 的复选框:
关于Maven的配置请网上查找,一定要使用本地的Maven仓库,要不会有一点问题:
elipse配置:
同时还要配置一个是eclipse的ini文件,修改vm如下所示:
-vm
C:\Program Files\Java\jdk1.6.0_27\bin
上面的是我的jdk安装目录中的bin文件夹
在eclipse中使用jdk编译器:
这样关于环境的配置都准备就绪了,打开eclipse进行import其中的sshpermission源码项目
因为我进行环境配置过了,所以和你们导入的有少许不同,没关系,下面我会教你们一步一步配置:
1.右键点击项目,选择Maven插件中的Disabled Dependency Management,然后右键点击项目,选择Maven中的Enable Dependency Manegement ,这是项目会把原来的依赖去掉,生成Maven依赖,方便我们使用tomcat部署
2.右键点击项目,选择properties,选择Java Build Path 的 Library
我们要使用jdk和tomcat的library
2.在source里面,我们要修改编译的输出路径,同时把Allow Output...的复选框选上
3.点击Deployment Assemby ,这时候会提示是否应用到当前项目中,点Apply,删除target目录
配置如下:
增加Maven的lib,要不项目在tomcat启动不来:
4.确认,此时我们要修改pom文件
4.1 pom中的junit 4.7 不知道为什么不行,所以,我们修改成4.10版本:
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> <scope>test</scope> </dependency>
同时修改build 如下:
<build> <finalName>tgOA</finalName> <sourceDirectory>src/main/java</sourceDirectory> <outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory> <defaultGoal>install</defaultGoal> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> <resource> <directory>src/main/java</directory> </resource> </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.6</source> <target>1.6</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <configuration> <webappDirectory>target</webappDirectory> <warSourceDirectory>src/main/webapp</warSourceDirectory> </configuration> </plugin> </plugins> </build>
此处贴一个完整版的pom
<project 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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.tgyt</groupId> <artifactId>tgOA</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>tgOA Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>3.0.5.RELEASE</spring.version> <jstl.version>1.1.2</jstl.version> <commons.beanutils.version>1.7.0</commons.beanutils.version> <commons.collections.version>3.2</commons.collections.version> <slf4j.version>1.6.1</slf4j.version> <struts2.version>2.2.1</struts2.version> <taglibs.version>1.1.2</taglibs.version> <spring.security.version>2.0.4</spring.security.version> </properties> <dependencies> <!-- ===== --> <dependency> <groupId>net.sourceforge.jexcelapi</groupId> <artifactId>jxl</artifactId> <version>2.6</version> </dependency> <dependency> <groupId>quartz</groupId> <artifactId>quartz</artifactId> <version>1.5.2</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>${taglibs.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> <version>${spring.security.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-taglibs</artifactId> <version>${spring.security.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core-tiger</artifactId> <version>${spring.security.version}</version> </dependency> <!-- cometd-bayeux --> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>cometd-bayeux</artifactId> <version>6.1.11</version> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>1.6</version> </dependency> <!-- ======== --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> <scope>test</scope> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>${commons.beanutils.version}</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>${commons.collections.version}</version> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>org.apache.ant</groupId> <artifactId>ant</artifactId> <version>1.8.2</version> </dependency> <!--*************************SLF4J 1.6.1 CONFIGURATION*********************** --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.6.1</version> </dependency> <!--*************************HIBERNATE JAP2.0 CONFIGURATION*********************** --> <dependency> <groupId>asm</groupId> <artifactId>asm-all</artifactId> <version>3.3</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>3.6.0.Final</version> <exclusions> <exclusion> <artifactId>asm</artifactId> <groupId>asm</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>3.6.0.Final</version> <type>jar</type> <scope>compile</scope> <exclusions> <exclusion> <artifactId>commons-collections</artifactId> <groupId>commons-collections</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-testing</artifactId> <version>3.6.0.Final</version> <type>jar</type> <scope>test</scope> </dependency> <!--*************************SPRIGN CONFIGURATION*********************** --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> <type>jar</type> <scope>compile</scope> <exclusions> <exclusion> <artifactId>commons-collections</artifactId> <groupId>commons-collections</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>${spring.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>${spring.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-asm</artifactId> <version>${spring.version}</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>aopalliance</groupId> <artifactId>aopalliance</artifactId> <version>1.0</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.14</version> </dependency> <!-- by ligangying --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <artifactId>mysql-connector-java</artifactId> <groupId>mysql</groupId> <version>5.0.5</version> </dependency> <!-- Struts 2 --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.2.1</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-config-browser-plugin</artifactId> <version>2.2.1</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-sitemesh-plugin</artifactId> <version>2.2.1</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-spring-plugin</artifactId> <version>2.2.1</version> </dependency> <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker-gae</artifactId> <version>2.3.18</version> </dependency> <dependency> <groupId>velocity</groupId> <artifactId>velocity-dep</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>webmacro</groupId> <artifactId>webmacro</artifactId> <version>1.1final</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.6.8</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.2.2</version> <type>jar</type> <classifier>jdk15</classifier> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-web</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>2.1_3</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.lucene</groupId> <artifactId>lucene-core</artifactId> <version>3.6.0</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.lucene</groupId> <artifactId>lucene-highlighter</artifactId> <version>3.6.0</version> <type>jar</type> <scope>compile</scope> </dependency> </dependencies> <build> <finalName>tgOA</finalName> <sourceDirectory>src/main/java</sourceDirectory> <outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory> <defaultGoal>install</defaultGoal> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> <resource> <directory>src/main/java</directory> </resource> </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.6</source> <target>1.6</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <configuration> <webappDirectory>target</webappDirectory> <warSourceDirectory>src/main/webapp</warSourceDirectory> </configuration> </plugin> </plugins> </build> </project>
此时我们保存,然后右键点击项目,Maven中的Update Dependencys,此时我们发现项目中多了不少错误
原因是缺少包,我们增加下依赖就好:
点击eclipse顶部工具栏的Porject中的Clean
修改一下resources中的init.properties
#数据库连接 datasource.url=jdbc:mysql://localhost/tgpermission?useUnicode=true&characterEncoding=utf-8&autoReconnect=true #用户名 datasource.username=root #密码 datasource.password=root
其中根据你的数据库修改,然后把项目部署到tomcat中,启动
http://localhost:8080/tgOA
成功!