尝试在Amazon Linux计算机上启动应用程序时出现以下错误。
Caused by: java.lang.IncompatibleClassChangeError: class com.google.common.cache.CacheBuilder$3 has interface com.google.common.base.Ticker as super class
at java.lang.ClassLoader.defineClass1(Native Method)
答案 0 :(得分:0)
该错误意味着<?php
$servername = "localhost";
$username = "enterusername";
$password = "enterdatabasepassword";
$database="enterdatabasename";
// Create connection
$con = mysqli_connect($servername, $username, $password,$database);
// Check connection
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
//this is a comment.
//Usually in localhost username is root and password is empty, so you must use
$username="root";
$password="";
3) Now you are connected to the database. This is how you get data from the database.
// $sql is just a variable
//$con is the variable that stores database connection. We declared it before.
$sql = mysqli_query($con, "SELECT * FROM album");
$count = mysqli_num_rows($sql); //mysqli_num_rows counts rows returned from database.
//now we check if database returned more than 0 rows
if($count>0){
//if returned rows >0 we fetch the data
while ($row = mysqli_fetch_array($sql)){
//Now we store each field in variables:
$id=$row['id'];
$name=$row['name'];
$number=$row['number'];
$year=$row['year'];
$artist=$row['artist'];
$description=$row['description'];
//Now we can create table
echo "<table><thead><tr> <td>id</td><td>name</td><td>number</td><td>year</td><td>artist</td><td>description</td></tr></thead>
<tbody>
<tr> <td>$id</td><td>$name</td><td>$number</td><td>$year</td><td>$artist</td><td>$description</td></tr>
</tbody>
</table>";
}
}
//Hope this helped you.
的字节码期望CacheBuilder
是Java类,但它是一个接口。
您在类路径上有两个版本的Guava,或者正在使用与您以前构建的版本不同的Guava启动应用程序。
尝试Ticker
并查找重复项。如果看起来不错,请在VM上运行应用程序时检查类路径。
在极少数情况下,可能有人“聪明”地将mvn dependency:tree
(或com.google.common.base.Ticker
)的字节码复制到了自己的JAR中。尝试在所有JAR上进行文本搜索以找到候选者或编写单元测试以打印
CacheBuilder
查看谁喜欢贡献(应该只返回一个URL)。如果可行,请对getClass().getClassLoader().getResources("com/google/common/base/Ticker.class");
执行相同操作。