我创建了一个Spring Boot应用程序,并使用要执行的方法创建了一个类。将项目部署为war文件时,出现错误:
我将显示代码的某些部分:
@Configuration
@EnableAsync
@EnableScheduling
@ComponentScan(basePackages={"parser", "service", "processing", "automation"})
public class TennisExecutor extends SpringBootServletInitializer {
@Autowired
public ParseUpcomingMatchesFile parseUpcomingMatchesFile;
@Autowired
public ParseFinishedMatchesFile parseFinishedMatchesFile;
@Autowired
public PlayersProcessor playersProcessor;
public TennisExecutor() {}
@Scheduled(cron = "0 */2 * * * ?")
public void executeTasks() throws IOException {
parseUpcomingMatchesFile.parseMatchesFile(webDriver, new File(ConstantData.TOMORROW_UPCOMING_MATCHES_FILE_PATH));
}
@Component
@EnableJpaRepositories(basePackageClasses={MatchesRepository.class, PlayersRepository.class})
@EntityScan(basePackageClasses={MatchesEntity.class, PlayersEntity.class})
public class ParseUpcomingMatchesFile {
@Autowired
public MatchesRepository matchesRepository;
@Autowired
public PlayersRepository playersRepository;
static final org.apache.log4j.Logger logger = Logger.getLogger(ParseUpcomingMatchesFile.class);
public ParseUpcomingMatchesFile() {
}
public void parseMatchesFile(WebDriver webDriver, File file) throws IOException {
String fullNameOne = "player1";
String fullNameTwo = "player2";
int matchId = matchesRepository.selectIdByPlayerNames(fullNameOne, fullNameTwo);
}
}
@Repository
public interface MatchesRepository extends CrudRepository<MatchesEntity, Integer> {
@Query(value = "select m from MatchesEntity m")
List<MatchesEntity> selectAllMatches();
@Query(value = "select m.id from MatchesEntity m where m.namePlayer1 = :namePlayer1 and " +
"m.namePlayer2 = :namePlayer2")
int selectIdByPlayerNames(String namePlayer1, String namePlayer2);
}
我试图删除.m2 / repository文件夹,添加了spring-data-jpa的依赖项,但没有任何变化。 有人有什么建议吗?