我已经在我的电脑上安装了 maven,如果我在 cmd 中输入“mvn --version”,我会得到:
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T14:57:37+03:00)
Maven home: C:\Users\mmmm\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3
Java version: 1.8.0_251, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_251\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"
Run Code Online (Sandbox Code Playgroud)
问题是,从 Intellij 中,如果我尝试从终端进行 mvn 全新安装,我会收到“'mvn' 未被识别为内部或外部命令、可运行的程序或批处理文件。”
我的系统变量包含这些:
M2_HOME = C:\Users\mmmm\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3
M2 = %M2_HOME%\bin
Path = %M2_HOME%\bin
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
我今天有一个 Java 面试,我被要求创建一个名为 Person 的不可变类,我得到了一个带有一些参数的骨架:年龄、名称等。我创建了以下类:
final class Person {
private final int age;
private final String name;
private final List<String> petNames;
public Person(int a, String n, List<String> p) {
this.age = a;
this.name = n;
this.petNames = p;
}
int getAget() {
return this.age;
}
String getName() {
return this.name;
}
List<String> getPetnames() {
return this.petNames;
}
}
Run Code Online (Sandbox Code Playgroud)
有人告诉我它不完整,因为通过执行以下代码序列,您证明它不是不可变的:
int x = 3;
String name = "Alex";
List<String> ls = new ArrayList<>();
Person p1 = new Person(x, name, ls);
Run Code Online (Sandbox Code Playgroud)
我得到的提示是它与列表有关,我应该在构造函数中更改某些内容。但我真的不知道为什么,我真的不明白出了什么问题。 …
我创建了一个 Spring Boot 应用程序,并使用我想要执行的方法创建了一个类。将项目部署为 war 文件时,我从堆栈跟踪中收到错误。我想运行 TennisExecutor 类中的方法。
我将展示我的代码的一些部分:
@Configuration
@EnableAsync
@EnableScheduling
@ComponentScan(basePackages={"parser", "service", "processing", "automation"})
public class TennisExecutor extends SpringBootServletInitializer {
@Autowired
@Qualifier("tennisDataSource")
private DataSource dataSource;
@Autowired
@Qualifier("tennisTm")
PlatformTransactionManager transactionManager;
@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));
}
Run Code Online (Sandbox Code Playgroud)
@Configuration
@EnableJpaRepositories(basePackageClasses = {ParseUpcomingMatchesFile.class, ParseFinishedMatchesFile.class,
PlayersProcessor.class}, entityManagerFactoryRef = "tennisEmf", …Run Code Online (Sandbox Code Playgroud)