line-height與vertical-align之行內元素佈局
maven建立工程目錄不全問題
原因是建立maven工程時沒有勾選create a simple project(skip archetype selection)項,而是隻勾選了Use default Workspace location然後選擇下一步的方式建立,這種方式建立的maven會缺少一些目錄。解決辦法是勾選create a simple project(skip archetype selection)項,然後直接在表單中輸入Group Id和Artifact Id即可。
配置阿里雲映象
<mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>
新增本地依賴包
新增本地依賴包:
<dependency> <groupId>com.jacob</groupId> <artifactId>jacob</artifactId> <version>1.19</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/jacob.jar</systemPath> </dependency>
如果不使用新增本地依賴包的方式,打包時就要在pom.xm加入下面的配置【不推薦】
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <source>${jdk.version}</source> <target>${jdk.version}</target> <showWarnings>true</showWarnings> <encoding>UTF-8</encoding> <!-- 這裡是新新增的 --> <compilerArguments> <!-- 對應jar放置在專案中的位置 --> <extdirs>lib</extdirs> </compilerArguments> </configuration> </plugin>
pom.xml
在dependency.version中引用version版本
<packaging>war</packaging> // 1.定義properties屬性 <!-- 專案屬性 --> <properties> <!-- main version setting --> <servlet.version>3.1.0</servlet.version> <struts2.version>2.3.4</struts2.version> </properties> // 在denpendance中引用 <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>${servlet.version}</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>${struts2.version}</version> </dependency> </dependencies>
使用jetty
<build> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.4.7.v20170914</version> <configuration> <webApp> <contextPath>/${build.finalName}</contextPath> </webApp> <stopKey>CTRL+C</stopKey> <stopPort>8999</stopPort> <scanIntervalSeconds>10</scanIntervalSeconds> <scanTargets> <scanTarget>src/main/webapp/WEB-INF/web.xml</scanTarget> </scanTargets> </configuration> </plugin> </plugins> </build>
如果使用的是eclipse整合的話:在maven bulid輸入:
jetty run
不是的話,需要輸入:
mvn jetty run
訪問地址是打過包的地址:
即:http://localhost:8080/Struts2Base-0.0.1-SNAPSHOT
maven打包
打包
專案右鍵 -> Run as -> Maven clean 等待執行成功後 -> 專案右鍵+Run as + Run Configurations 在Goals輸入框中輸入:
package
然後 run即可。
出現的問題
1、打包報錯:程式包javax.validation不存在
解決方法:清空mvn倉庫下的javax包,然後重新使用maven下載
2、打包報錯:程式包com.jacob.activeX不存在
解決方法:不在使用在jar包上右擊add to build path方式,這種方式打包是不會把該程式包打進去,所以打包時會報錯。解決方式就是使用新增本地依賴包的形式將本地的jacob加入maven中,詳見【@ link 新增本地依賴包一章】
3、打包報錯:在打包測試程式時報錯:找不到符號
解決方法:打包時忽略測試程式包:Run Configuration中的Goals中填寫:
package -Dmaven.test.skip=true
然後,run即可。
4、eclipse預設使用的時jre1.6版本,如果將jre版本更改為1.8也會導致打包出錯
常見報錯
error:web.xml is missing and <failOnMissingWebXml> is set to true
resolve:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
error:Java compiler level does not match the version of the installed Java project facet.
error:Dynamic Web Module 3.1 requires Java 1.7 or newer.
resolve:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <!-- 如果是1.8,修改為1.8 --> <target>1.8</target> <!-- 如果是1.8,修改為1.8 --> </configuration> </plugin>
maven建立工程目錄不全問題
原因是建立maven工程時沒有勾選create a simple project(skip archetype selection)項,而是隻勾選了Use default Workspace location然後選擇下一步的方式建立,這種方式建立的maven會缺少一些目錄。解決辦法是勾選create a simple project(skip archetype selection)項,然後直接在表單中輸入Group Id和Artifact Id即可。
配置阿里雲映象
<mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>
新增本地依賴包
新增本地依賴包:
<dependency> <groupId>com.jacob</groupId> <artifactId>jacob</artifactId> <version>1.19</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/jacob.jar</systemPath> </dependency>
如果不使用新增本地依賴包的方式,打包時就要在pom.xm加入下面的配置【不推薦】
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <source>${jdk.version}</source> <target>${jdk.version}</target> <showWarnings>true</showWarnings> <encoding>UTF-8</encoding> <!-- 這裡是新新增的 --> <compilerArguments> <!-- 對應jar放置在專案中的位置 --> <extdirs>lib</extdirs> </compilerArguments> </configuration> </plugin>