我在学习如何使用Spotify API,但他们的sample code不起作用。我的java代码不起作用(NoClassDefFoundError)
我正在使用Netbeans 8.1,我确实导入了.jar文件,并且在Api api = Api.builder()
行中显示java.lang.NoClassDefFoundError: net/sf/json/JSON
。
import com.wrapper.spotify.Api;
import com.wrapper.spotify.methods.AlbumRequest;
import com.wrapper.spotify.models.Album;
import java.util.List;
public static void main(String[] args) {
// Create an API instance. The default instance connects to https://api.spotify.com/.
Api api = Api.builder()
.clientId("<secret>")
.clientSecret("<secret>")
.redirectURI("<secret>")
.build();
// Create a request object for the type of request you want to make
AlbumRequest request = api.getAlbum("7e0ij2fpWaxOEHv5fUYZjd").build();
// Retrieve an album
try {
Album album = request.get();
// Print the genres of the album
List<String> genres = album.getGenres();
for (String genre : genres) {
System.out.println(genre);
}
} catch (Exception e) {
System.out.println("Could not get albums.");
}
}
我的回答有帮助吗? https://stackoverflow.com/help/someone-answers – user7294900
@ user7294900实际上,在我了解到有关maven的更多信息之后,我可以看到问题,但是有帮助。 –