Project Structure – File by Type or File by Feature

I am using an AngularJS style guide. This guide contains a style called folder by feature, instead of folder by typeand I am curious to know which is the best approach (in this example for Java)

Suppose I have an application for recovering users and pets with the help of services, controllers, repositories and ofcourse domain objects.

By taking styles back by b, we have two options for our packaging structure:

1. File by type

com.example
├── domain
├── User.java
└── └── Pet.java
├── controllers
├── UserController.java
└── PetController.java
├── repositories
├── UserRepository.java
└── PetRepository.java
├── services
├── UserService.java
└── PetService.java
// and all the rest of the project
└── MyApplication.java

2. Feature by Feature

com.example
├── animal
├── ├── Pet.java
├── PetController.java
├── PetRepository.java
└── PetService.java
├── user
├── User.java
├── UserController.java
├── UserRepository.java
└── UserService.java
// and all the rest of the project
└── MyApplication.java

What would be a good approach and what are the arguments for doing it?