How to invoke repository method for standalone application?

Viewed 406

I have following repository which extends jpa repositroy and also have an implementation class where i have autowired this.

@Repository
public interface ProjectDAO extends CrudRepository<Project, Integer> {}

@Service
public class ProjectServiceImpl {

@Autowired private ProjectDAO pDAO;

public void save(Project p) { pDAO.save(p); } }

Now i have one Application.java class

Class Application{
public static void main(String..s){
// I need a way to call a method of repository
}
}

configuration file

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories
@PropertySource("file:/Users/abc/Documents/application.properties")
public class PersistenceContext {
    @Autowired
    Environment environment;

So how do we call this from main in case i dont to use any web based controller?

1 Answers
Related