我在學習如何使用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的更多信息之後,我可以看到問題,但是有幫助。 –