1. 程式人生 > >maven搭建ssm框架問題總結

maven搭建ssm框架問題總結

error odi more 3.6 env 但是 exception finish ant

1. Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:compile (default-compile) on project jcseg-core: Compilation failure
[ No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

解決:把 JRE 路徑從 JRE 改成 JDK:
Window → Preferences → 對話框中的左側選擇Java → Installed JREs → 對話框右側點擊 Add 按鈕 → Standard VM → next → JRE home 選擇 JDK 的安裝路徑 → Finish → 選中 jdk 的復選框 → 點擊 OK 按鈕
按照《Maven實戰》的內容,建議你不要使用 eclipse 內嵌的 Maven。而是給 eclipse 配置電腦上安裝的 Maven。這樣保證版本一致,可以避免一些問題。

2.Caused by: java.net.BindException: Address already in use: JVM_Bind <null>:8080
解決:端口被占用,可能運行兩次tomcat

3.嚴重: Compilation error org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException:
嚴重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 1 in the generated java file
The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

解決:項目正常啟動,但是無法在瀏覽器中打開,報的錯是 org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException,是tomcat:run的問題
在web項目的pom文件中增加tomcat7配置

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>9999</port>
<uriEncoding>UTF-8</uriEncoding>
</configuration>
</plugin>
啟動tomcat插件,不過這次的命令不是tomcat:run 而是tomcat7:run 因為前者不會調用tomcat7;

4.ssm整合時出現
java.sql.SQLException: The server time zone value ‘?й???????‘ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value ‘?й???????‘ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

解決:配置pom.xml時使用的是MySQL最新jar包,原來新版的驅動配置有些變化:

1. url連接必須設置時區
### MySQL Connector/J 5.x (舊版連接)
#jdbc.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8

### MySQL Connector/J 6.x (新版連接)
jdbc.url=jdbc:mysql:///test?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=false

說明: 新版驅動url默認地址為127.0.0.1:3306,所以訪問本機mysql數據庫地址可以用 /// 表示。

2. 新的驅動類位置有了變化(不影響使用,但會報警告)

### MySQL Connector/J 5.x (舊版驅動)
#jdbc.driver_class=com.mysql.jdbc.Driver

### MySQL Connector/J 6.x (新版驅動)
jdbc.driver_class=com.mysql.cj.jdbc.Driver

maven搭建ssm框架問題總結