Vagrant uses Virtualbox to manage the virtual dependencies. You can directly download virtualbox and install or use homebrew for it.
$ brew cask install virtualbox
Now install Vagrant either from the website or use homebrew for installing it.
@Setter | |
@Getter | |
@NoArgsConstructor | |
@AllArgsConstructor | |
@SuperBuilder | |
@MappedSuperclass | |
public class BaseEntity { | |
@Id | |
@GeneratedValue(generator = "UUID") |
@SuperBuilder | |
@Setter | |
@Getter | |
@NoArgsConstructor | |
@AllArgsConstructor | |
@MappedSuperclass | |
public class BaseEntity { | |
@Id | |
@GeneratedValue(generator = "UUID") |
Typing vagrant
from the command line will display a list of all available commands.
Be sure that you are in the same directory as the Vagrantfile when running these commands!
vagrant init
-- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.vagrant init <boxpath>
-- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64
.vagrant up
-- starts vagrant environment (also provisions only on the FIRST vagrant up)@Component | |
public class CustomErrorAttributes extends DefaultErrorAttributes { | |
@Override | |
public Map<String, Object> getErrorAttributes(WebRequest webRequest, ErrorAttributeOptions options) { | |
Map<String, Object> errorAttributes = new LinkedHashMap(); | |
Map<String, Object> attributes = super.getErrorAttributes(webRequest, options); | |
long timestamp = ((Date) attributes.get("timestamp")).getTime(); |
public interface VoteRepository extends JpaRepository<Vote, Long> { | |
@Query("SELECT NEW com.example.polls.model.ChoiceVoteCount(v.choice.id, count(v.id)) FROM Vote v WHERE v.poll.id in :pollIds GROUP BY v.choice.id") | |
List<ChoiceVoteCount> countByPollIdInGroupByChoiceId(@Param("pollIds") List<Long> pollIds); | |
@Query("SELECT NEW com.example.polls.model.ChoiceVoteCount(v.choice.id, count(v.id)) FROM Vote v WHERE v.poll.id = :pollId GROUP BY v.choice.id") | |
List<ChoiceVoteCount> countByPollIdGroupByChoiceId(@Param("pollId") Long pollId); | |
@Query("SELECT v FROM Vote v where v.user.id = :userId and v.poll.id in :pollIds") | |
List<Vote> findByUserIdAndPollIdIn(@Param("userId") Long userId, @Param("pollIds") List<Long> pollIds); |
@ControllerAdvice | |
public class CustomExceptionControllerAdvice { | |
@ExceptionHandler(MultipartException.class) | |
void handleMultipartException(MultipartException ex,HttpServletResponse response) throws IOException { | |
response.sendError(HttpStatus.BAD_REQUEST.value(),"Please select a file"); | |
} | |
@ExceptionHandler(ConstraintViolationException.class) | |
public void handleConstraintViolationException(ConstraintViolationException ex,HttpServletResponse response) throws IOException { |
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) | |
public class AppException extends RuntimeException { | |
public AppException(String message) { | |
super(message); | |
} | |
public AppException(String message, Throwable cause) { | |
super(message, cause); | |
} | |
} |
@Configuration | |
public class ForwardedHeaderFilterConfig { | |
@Bean | |
public FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter() { | |
FilterRegistrationBean<ForwardedHeaderFilter> result = new FilterRegistrationBean<>(); | |
result.setFilter(new ForwardedHeaderFilter()); | |
result.setOrder(0); | |
return result; | |
} |