maven添加gson依赖,GSON未导入到Maven项目中

I am getting the following error - I have added the GSon in my dependency -

Can someone point out what I am doing wrong?

010cf4b4f896f3fa9b74e556ffd0dece.png

Edit : dependency specified -

com.google.code.gson

gson

1.7.1

I am using the following code in my sevlet -

JSONService json = new JSONService();

String json_output = json.makeLoginJSON(user);

makeLoginJSON ---

public String makeLoginJSON(LoginDetails user) {

String FinalJson = null;

Gson gson = new Gson();

FinalJson = gson.toJson(user);

return FinalJson;

}

解决方案

Try:

com.google.code.gson

gson

2.1

provided

I have edited my comment and added the scope. The default scope is compile, meaning that the dependency is not present at runtime. For this, you use the provided scope. More about scopes in maven dependencies on Apache's Introduction to Maven Dependencies.

Hope this resolves your issue.

P.S.: if you are creating your own repository, you should also take a look here.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值