1. 程式人生 > >給我一個maven結構的war包,反編譯成專案併成功執行起來

給我一個maven結構的war包,反編譯成專案併成功執行起來

開發工具eclipse,idea,反編譯工具jq-gui

1.用eclipse建立一個maven結構的web專案
裡寫圖片描述
將第一項勾選,跳過選擇maven結構型別,下一步的jar包型別一定要選擇war包型別,其他自定義,

這裡寫圖片描述
標準的maven結構,webapp裡面的檔案可以自己建。

pom檔案以下配置注意兩點,maven依賴包如果是私有包必須通過maven打包命令打進本地倉庫再引用。打本地倉命令:mvn install:install-file -Dfile=E:\內網通檔案\杜青\WEB-INF\lib\proxool-cglib.jar -DgroupId=proxool -DartifactId=proxool-cglib -Dversion=0.9.1 -Dpackaging=jar

<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.cosw</groupId>
  <artifactId>trans</artifactId
>
<packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>trans Maven Webapp</name> <!--<url>http://maven.apache.org</url>--> > ## 這裡可以配置pom檔案的屬性值,便於全域性通用 ## <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding
>
<springVersion>4.3.7.RELEASE</springVersion> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.1</version> </dependency> <!-- servlet --> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <scope>provided</scope> <version>3.0-alpha-1</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> <scope>provided</scope> <version>2.0</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>1.1.2</version> </dependency> <!--logger begin --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.1</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> <!-- logger end --> <!-- spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${springVersion}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${springVersion}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${springVersion}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${springVersion}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>4.3.7.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>${springVersion}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${springVersion}</version> </dependency> <!-- 使用SpringMVC需配置 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${springVersion}</version> </dependency> <!-- 關係型資料庫整合時需配置 如hibernate jpa等 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${springVersion}</version> </dependency> <!-- spring end --> <!-- aop --> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.8.4</version> </dependency> <!-- hibernate begin --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.3.8.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-ehcache</artifactId> <version>4.3.8.Final</version> </dependency> <!-- 二級快取ehcache <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache</artifactId> <version>2.9.0</version> </dependency> --> <!--enable hibernate to use its proxy model --> <dependency> <groupId>javassist</groupId> <artifactId>javassist</artifactId> <version>3.9.0.GA</version> </dependency> <!-- hibernate end --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.5.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.5.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.5.0</version> </dependency> <!-- apache commons begin --> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>commons-httpclient</groupId> <artifactId>commons-httpclient</artifactId> <version>3.1</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.10</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2.1</version> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.9.0</version> </dependency> <!--定時任務排程使用 --> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>2.2.1</version> </dependency> <!-- jackson begin --> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-core-lgpl</artifactId> <version>1.2.1</version> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-lgpl</artifactId> <version>1.2.1</version> </dependency> <!-- jackson end --> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.2.4</version> </dependency> <!-- jdbc --> <!-- <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> </dependency> --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.30</version> </dependency> <!-- proxool --> <dependency> <groupId>proxool</groupId> <artifactId>proxool</artifactId> <version>0.9.1</version> </dependency> <dependency> <groupId>proxool</groupId> <artifactId>proxool-cglib</artifactId> <version>0.9.1</version> </dependency> <!-- json --> <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>xom</groupId> <artifactId>xom</artifactId> <version>1.2.5</version> </dependency> <dependency> <groupId>net.sf.ezmorph</groupId> <artifactId>ezmorph</artifactId> <version>1.0.6</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.3</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpmime</artifactId> <version>4.3</version> </dependency> <!-- xmlpull --> <dependency> <groupId>xmlpull</groupId> <artifactId>xmlpull</artifactId> <version>1.1.3.4a</version> </dependency> <dependency> <groupId>kxml2</groupId> <artifactId>kxml2</artifactId> <version>2.3.0</version> </dependency> <!-- xmlpull end --> <!-- com.cosw --> <dependency> <groupId>com.cosw</groupId> <artifactId>commons-util</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>com.cosw</groupId> <artifactId>commons-card</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>com.cosw</groupId> <artifactId>commons-hsm</artifactId> <version>1.0</version> </dependency> <!-- qianhui --> <dependency> <groupId>com.cosw</groupId> <artifactId>qh-card-service</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>com.cosw</groupId> <artifactId>qh-card-protocol</artifactId> <version>1.0</version> </dependency> </dependencies> ## build打包編譯並部署到jetty ## <build> <finalName>ncuboss</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.5</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> <version>2.4</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.6</version> <configuration> <webResources> <resource> <directory>${project.basedir}/lib</directory> <targetPath>WEB-INF</targetPath> <filtering>true</filtering> <includes> <include>*.jar</include> </includes> </resource> </webResources> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.4</version> <executions> <execution> <id>copy</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>src/main/webapp/WEB-INF/lib</outputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.0-beta-1</version> <configuration> <url>http://localhost:8080/manager/text</url> <server>tomcat</server> <path>/ncuboss</path> <!-- <URIEncoding>UTF-8</URIEncoding>--> </configuration> </plugin> ## jetty服務外掛以及配置 ## <!-- 9.3.8.v20160314 --> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.26</version> <configuration> <connectors> <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> <port>9090</port> </connector> </connectors> <scanIntervalSeconds>10</scanIntervalSeconds> <webAppConfig> <contextPath>/trans</contextPath> </webAppConfig> </configuration> </plugin> </plugins> </build> </project>

解決Cannot change version of project facet Dynamic web module to 2.5
這裡寫連結內容

最近做的一個專案中運用到了連線池技術,可能我們大家比較熟悉的開源連線池有dbcp,c3p0,proxool。對這三種連線池來說,從效能和出錯率來說,proxool稍微比前兩種好些。今天我主要簡單的講述一下proxool,我在專案中成功的配置和原始碼。

    第一步:首先去http://proxool.sourceforge.net/下載一個proxool.jar檔案了,我用的是proxool-0.9.0RC3.jar,現在最新版本是proxool-0.9.1.jar,我在用這個JAR包時,老是報如下錯誤: 

嚴重: Servlet.service() for servlet action threw exception
java.lang.NoClassDefFoundError: org/logicalcobwebs/cglib/proxy/Callback
at org.logicalcobwebs.proxool.ConnectionPool.getConnection(ConnectionPool.java:261)
at org.logicalcobwebs.proxool.ProxoolDriver.connect(ProxoolDriver.java:89)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)

最後換用proxool-0.9.0RC3.jar無此問題,哪們知道解決辦法的話,請留言.
.除了他們的檢視監控臺的頁面有變化,其他的變化不是太大。

這裡寫圖片描述

換了jar包之後,CallBack類就可以找到了。以上就是在整個過程中遇到的比較難的問題,備忘下。