Boots Bootique Challenge - please unstuck me

So I’m trying to solve the Boots Boutique challenge at Java & Spring API course. I’m at step 6, where after my updates the pre-defined exercise UI should be updated with correct values, but it doesn’t update for me, and I can’t see why. I’ve reset the exercise, followed official walkthrough and checked everything again, nothing. It must be my flaw somewhere in the code, but since we don’t get to actually see error messages in these kind of challenges, I struggle to see why doesn’t it work.

Here is the link to the challenge:
https://www.codecademy.com/paths/create-rest-apis-with-spring-and-java/tracks/spring-apis-data-with-jpa/modules/spring-data-and-jpa/projects/spring-data-jpa-the-boots-bootique

Here’s my application.properties file:

server.port=4001
spring.jackson.default-property-inclusion = NON_NULL
spring.jpa.defer-datasource-initialization= true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.hibernate.hbm2ddl.auto=create
spring.jpa.hibernate.use-new-id-generator-mappings=false
spring.datasource.initialization-mode=always
spring.datasource.url=jdbc:h2:file:~/boots.db

Here is my Boot.java:

package com.codecademy.boots.entities;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.Enumerated;
import javax.persistence.EnumType;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;

import com.codecademy.boots.enums.BootType;

@Entity
@Table(name="BOOTS")
public class Boot {

  @Id
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  private Integer id;

  @Enumerated(EnumType.STRING)
  @Column(name="TYPE")
  private BootType type;

  @Column(name="SIZE")
  private Float size;
  
  @Column(name="QUANTITY")
  private Integer quantity;

  @Column(name="MATERIAL")
  private String material;

  public Integer getId() {
    return this.id;
  }

  public void setId(Integer id) {
    return this.id = id;
  }

  public BootType getType() {
    return this.type;
  }

  public void setType(BootType type) {
    return this.type = type;
  }

  public Float getSize() {
    return this.size;
  }

  public void setSize(Float size) {
    return this.size = size;
  }

  public Integer getQuantity() {
    return this.quantity;
  }

  public void setQuantity(Integer quantity) {
    return this.quantity = quantity;
  }

  public String getMaterial() {
    return this.material;
  }

  public String setMaterial(String material) {
    return this.material = material;
  }
}

Here is BootRepository:

package com.codecademy.boots.repositories;

import java.util.List;

import org.springframework.data.repository.CrudRepository;

import com.codecademy.boots.entities.Boot;
import com.codecademy.boots.enums.BootType;

public interface BootRepository extends CrudRepository<Boot, Integer> {
}

and the last, BootController:

package com.codecademy.boots.controllers;

import java.lang.Iterable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Arrays;
import java.util.Optional;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import com.codecademy.boots.entities.Boot;
import com.codecademy.boots.enums.BootType;
import com.codecademy.boots.exceptions.QueryNotSupportedException;
import com.codecademy.boots.exceptions.NotImplementedException;

@RestController
@RequestMapping("/api/v1/boots")
public class BootController {

  private final BootRepository bootRepository;

  public BootController(final BootRepository bootRepository) {
    this.bootRepository = bootRepository;
  }

	@GetMapping("/")
	public Iterable<Boot> getAllBoots() {
    return this.bootRepository.findAll();
		
	}

	@GetMapping("/types")
	public List<BootType> getBootTypes() {
		return Arrays.asList(BootType.values());
	}

	@PostMapping("/")
	public Boot addBoot(@RequestBody Boot boot) {
		throw new NotImplementedException("Don't have the ability to add boots to the inventory yet!");
	}

	@DeleteMapping("/{id}")
	public Boot deleteBoot(@PathVariable("id") Integer id) {
		throw new NotImplementedException("Don't have the ability to delete boots yet!");
	}

	@PutMapping("/{id}/quantity/increment")
	public Boot incrementQuantity(@PathVariable("id") Integer id) {
		throw new NotImplementedException("Don't have the ability to increment boot counts yet!");
	}

	@PutMapping("/{id}/quantity/decrement")
	public Boot decrementQuantity(@PathVariable("id") Integer id) {
		throw new NotImplementedException("Don't have the ability to decrement boot counts yet!");
	}

	@GetMapping("/search")
	public List<Boot> searchBoots(@RequestParam(required = false) String material,
			@RequestParam(required = false) BootType type, @RequestParam(required = false) Float size,
			@RequestParam(required = false, name = "quantity") Integer minQuantity) throws QueryNotSupportedException {
		if (Objects.nonNull(material)) {
			if (Objects.nonNull(type) && Objects.nonNull(size) && Objects.nonNull(minQuantity)) {
				// call the repository method that accepts a material, type, size, and minimum
				// quantity
				throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
			} else if (Objects.nonNull(type) && Objects.nonNull(size)) {
				// call the repository method that accepts a material, size, and type
				throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
			} else if (Objects.nonNull(type) && Objects.nonNull(minQuantity)) {
				// call the repository method that accepts a material, a type, and a minimum
				// quantity
				throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
			} else if (Objects.nonNull(type)) {
				// call the repository method that accepts a material and a type
				throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
			} else {
				// call the repository method that accepts only a material
				throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
			}
		} else if (Objects.nonNull(type)) {
			if (Objects.nonNull(size) && Objects.nonNull(minQuantity)) {
				// call the repository method that accepts a type, size, and minimum quantity
				throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
			} else if (Objects.nonNull(size)) {
				// call the repository method that accepts a type and a size
				throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
			} else if (Objects.nonNull(minQuantity)) {
				// call the repository method that accepts a type and a minimum quantity
				throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
			} else {
				// call the repository method that accept only a type
				throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
			}
		} else if (Objects.nonNull(size)) {
			if (Objects.nonNull(minQuantity)) {
				// call the repository method that accepts a size and a minimum quantity
				throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
			} else {
				// call the repository method that accepts only a size
				throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
			}
		} else if (Objects.nonNull(minQuantity)) {
			// call the repository method that accepts only a minimum quantity
			throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
		} else {
			throw new QueryNotSupportedException("This query is not supported! Try a different combination of search parameters.");
		}
	}

}

I simply can’t see anything except for the white screen when I try to reach localhost:4001/, localhost, localhost:4001/api/v1/boots/ or anything like this. Can you help me to find the flaw in my code?

1 Like

I’m having the same issue. I’ve checked and rechecked my code and followed the walkthrough, but the website goes ‘blank’. When I try running ‘mvn compile’ in the console I am getting compilation errors. Can’t copy and paste, so will summarize:

  • Does not recognize variable GenerationType
  • Enum annotation type must be an enum constant
  • Does not recognize BootRepository class
    (I have tried an import statement as shown in the hint, but his makes no difference)
    To the OP, did you manage to get unstuck? Or if anyone is out there that could advise me, I’d appreciate it. Have been working on this for hours.

I get similar issues. I feel like there may be dependencies that need updating or something here. I’ve followed the walk through video now to make sure that my code is line by line character by character the same and I still get the errors. I’ve reported a bug and we’ll see if we get any info.

I found a fix somewhere! Let me track it down.
Ok here is a link to another discussion. There are a couple of imports missing. See if these help.

1 Like

Oh my gosh thank you. You know the whole time I was like… it doesn’t look like we are importing the repository but I thought it might be springboot magic that just lets it know… but this cleared all my errors thank you!

1 Like

You’re welcome! I’m happy I was able to find resolution and help someone else too. :slightly_smiling_face:

1 Like