简体   繁体   English

使用Maven在命令行上创建Java类和Java包

[英]Creating java classes and java package on command line using maven

I have created a java spring mvc application using eclipse and ii am running it using java mvn on my command line mvn package and mvn tomcat7:run and everything works out. 我已经使用eclipse创建了一个java spring mvc应用程序,并且我正在命令行mvn包和mvn tomcat7:run上使用java mvn运行它,一切正常。 However, i want to generate a new java package. 但是,我想生成一个新的Java包。 I have this packages that already exists 我有这个已经存在的软件包

在此处输入图片说明

com.boilerplate.configs
com.boilerplate.controllers
com.boilerplate.models
com.boilerplate.services

are all packages i created while i was on eclipse. 是我在日食时创建的所有软件包。 Inside each package, there are classes that i have created,for instance there is a class BoilerplateController.java inside of controllers. 在每个包中,都有我创建的类,例如,控制器内部有一个BoilerplateController.java类。

How can i add a package using for instance com.boilerplate.aws using maven or java?. 如何使用Maven或Java使用com.boilerplate.aws添加软件包?

A package is just a directory. 包只是一个目录。 Use a file explorer or command line stuff. 使用文件浏览器或命令行内容。

In java, you could write 在Java中,您可以编写

new File("src/main/java/com/boilerplate/package2").mkdirs()

But you are probably mistaking the concepts here. 但是您可能在这里误解了这些概念。 Use the IDE, such as Eclipse, to write the code, and use mvn to build it and java to execute it. 使用诸如Eclipse之类的IDE来编写代码,并使用mvn来构建它,并使用java来执行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM