Coloquei as seguinte dependência que o professor disponibiliza no curso, porem ela não importa a lib do json.
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Meu pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.casadocodigo</groupId>
<artifactId>casadocodigo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<finalName>casadocodigo</finalName>
</build>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.jboss.spec.javax.faces</groupId>
<artifactId>jboss-jsf-api_2.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>3.0.3.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Código da minha classe que não importa o Json
package br.com.casadocodigo.loja.models;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import br.com.casadocodigo.loja.daos.CompraDao;
@Named
@SessionScoped
public class CarrinhoCompras implements Serializable{
private static final long serialVersionUID = 1L;
@Inject
private CompraDao compraDao;
private Set<CarrinhoItem> itens =
new HashSet<>();
public void add(CarrinhoItem item) {
itens.add(item);
}
public List<CarrinhoItem> getItens() {
return new ArrayList<CarrinhoItem>(itens);
}
public BigDecimal getTotal(CarrinhoItem item) {
return item.getLivro().getPreco().multiply(
new BigDecimal(item.getQuantidade()));
}
public BigDecimal getTotal() {
BigDecimal total = BigDecimal.ZERO;
for (CarrinhoItem carrinhoItem : itens) {
total = total.add(carrinhoItem.getLivro().getPreco()
.multiply(new BigDecimal(carrinhoItem.getQuantidade())));
}
return total;
}
public void remover(CarrinhoItem item) {
this.itens.remove(item);
}
public Integer getQuantidadeTotal() {
return itens.stream().mapToInt(item -> item.getQuantidade()).sum();
}
public void finalizar(Usuario usuario) {
Compra compra = new Compra();
compra.setUsuario(usuario);
compra.setItens(this.toJson());
compraDao.salvar(compra);
}
private String toJson() {
Json.createArrayBuilder();
return "{}";
}
}