Maven 如何影响 Java Web 应用程序?
我正在使用 Netbeans 开始一个新的 Java Web 应用程序,并且我想使用 Maven。 McAfee 安装在我的盒子上(在工作中),这使我无法关闭文档文件夹(存储我的 Web 应用程序项目的位置)中的只读属性。我可以运行传统的 Web 应用程序项目,并在浏览器上显示“hello world”屏幕。但是,如果我尝试运行新的 Maven 项目,我会在控制台输出屏幕中看到“访问被拒绝”。为什么会发生这种情况,有解决方法吗?这是控制台输出:
------------------------------------------------------------------------
Building mavenproject1 1.0-SNAPSHOT
------------------------------------------------------------------------
[dependency:copy]
[resources:resources]
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\mavenproject1\src\main\resources
[compiler:compile]
Nothing to compile - all classes are up to date
[resources:testResources]
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\mavenproject1\src\test\resources
[compiler:testCompile]
Nothing to compile - all classes are up to date
[surefire:test]
No tests to run.
Surefire report directory: C:\mavenproject1\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
There are no tests to run.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[war:war]
Packaging webapp
Assembling webapp [mavenproject1] in [C:\mavenproject1\target
\mavenproject1-1.0-SNAPSHOT]
Processing war project
Copying webapp resources [C:\mavenproject1\src\main\webapp]
Webapp assembled in [25 msecs]
Building war: C:\mavenproject1\target\mavenproject1-1.0-SNAPSHOT.war
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 2.090s
Finished at: Thu Jan 12 08:48:22 EST 2012
Final Memory: 7M/17M
------------------------------------------------------------------------
Access is denied.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
该问题很可能是由于无法写入 Maven 存储库造成的。您可以通过“首选项”页面覆盖此存储库的位置。将位置指向计算机上的可写目录:
The problem is most likely due to not being able to write to the Maven repository. You can overwrite the location of this repository via the Preferences page. Point the location to a writable directory on your computer:
您可能必须更改 Maven 存储库默认路径。 Maven 将下载的工件存储在用户主目录中。更改 Netbeans 设置中的文件夹(查找 maven 选项卡)。
You probably have to change Maven reposotory default path. Maven stores downloaded artifacts in user home. Change the folder in Netbeans settings (look for maven tab).
maven 是您的 Web 应用程序的外部程序,您的防病毒软件应授予其读取文件并在同一目录中生成一些其他文件(包含已编译类的目标文件夹)的权限。
maven is an external program to your web application and your antivirus should give it permission to read the files and generate some other files (target folder with compiled classes) in the same directories.
您的防火墙正在阻止 NetBeans 将其连接到 Maven 存储库。 Maven 是一个为您的项目提供必要的 jar 的工具,这样您就不必手动添加它们。
但是,您仍然需要将所有需要的 jar(及其版本和其他信息)指定到项目配置文件(在 POM.xml 中)。在构建时,maven 访问配置并从 maven 存储库下载 jar。
Maven 存储库
Maven 完整参考
Your firewall is preventing the NetBeans to connect it to Maven Repository. Maven is a tool which provides the necessary jars to your project so that you don't have to add them manually.
However you still need to specify all the needed jars (along with their versions and other information) to a project configuration file (in POM.xml) . Than at build time the maven accesses the configuration and downloads the jars from maven repository.
Maven Repository
The Complete Reference to Maven
当您构建 pproject 时,Maven 将尝试创建各种文件,通常在名为“target”的文件夹中。它还会将依赖项下载到您的主目录(通常在子文件夹“.m2/repository”中),
我不确定您打算如何在只读文件系统上创建 web 应用程序。
Maven will try to create various files when you build a pproject, usually in a folder called "target". It will also download dependencies to your home directory (usually in a subfolder ".m2/repository"),
I'm not sure how you plan to make a webapp on a read-only filesystem.