经过数周的努力,我发布了这个帖子.我尝试尝试,因为我感到内疚,因为有类似于此的线程.但是我的错误仍然略有不同.所以我所拥有的是一个非常简单的弹簧(当然不需要弹簧bcz问题是maven)应用程序与maven.
这是我的pom的插件部分.
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://localhost:8080/manager</url>
<username>tomcat</username>
<password>s3cret</password>
<path>/Test</path>
<port>8080</port>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
早些时候我有maven tomcat插件无法使用tomcat 7等问题,但现在用"tomcat7-maven-plugin"解决了.我正在使用' http://localhost:8080/manager'作为URL.对于这个maven tomcat编译器插件的几乎所有线程都是关于构建失败的.但我的构建成功(我运行tomcat7:deploy).问题是tomcat正在回复
tomcatManager状态码:403,ReasonPhrase:Forbidden
以及我们在浏览器上遇到身份验证失败时看到的html.在我的Linux机器下,相同的代码工作正常.我尝试在settings.xml中使用server元素的不同场景,它位于.m2内部和maven_home/conf等内部.仍然无效.
正如我弄清楚maven无法验证tomcat.找到用户名和密码,我可以使用GUI登录.所以期待在这里提供帮助.
ps - 我的tomcat-users.xml fiel
<role rolename="manager-gui" />
<user username="tomcat" password="s3cret" roles="manager-gui"/>
Run Code Online (Sandbox Code Playgroud) 我的问题正是这个maven-shade插件用户面临的问题:
但我正在使用tomcat7-maven-plugin构建一个自运行的webapp.我最近切换了数据库驱动程序以使用Microsoft自己的驱动程序来实现JDBC4.现在我有问题,包括它作为我的exec-war目标中的extraDependency.这是相关部分pom.xml.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>tomcat-run</id>
<goals>
<goal>exec-war-only</goal>
</goals>
<phase>package</phase>
<configuration>
<path>/oases</path>
<contextFile>applicationContext.xml</contextFile>
<extraDependencies>
<extraDependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</extraDependency>
</extraDependencies>
<excludes>
<exclude>META-INF/MSFTSIG.RSA</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
该项目构建正常,但maven不遵守该exclude指令,以便sqljdbc4 RSA文件包含在META-INF目录中.这意味着当我尝试运行我的exec-war jar文件时,我收到此错误.
Exception in thread "main" java.lang.SecurityException: Invalid
signature file digest for Manifest main attributes
Run Code Online (Sandbox Code Playgroud)
我已经阅读了代码,据我所知,插件已正确配置为排除sqljdbc4 META-INF文件.这是版本2.2的插件代码,这是我正在使用的.看起来这应该做我想要的.然而,exec-war jar仍包括META-INF/MSFTSIG.RSA
protected void extractJarToArchive( JarFile file, ArchiveOutputStream os, String[] excludes )
throws IOException
{
Enumeration<? extends JarEntry> entries = file.entries();
while ( entries.hasMoreElements() )
{ …Run Code Online (Sandbox Code Playgroud) 我们有一个应用程序,直到最近才是一个单一的Maven WAR项目.我们使用Tomcat Maven插件在本地开发人员工作站上运行应用程序:
mvn tomcat:run
Run Code Online (Sandbox Code Playgroud)
我们能够在嵌入式Tomcat实例运行时更改JSP文件,并且更改将在Web浏览器中正常显示.我理解(从插件文档中)当使用tomcat:run目标时,WAR作为动态Web应用程序加载,因此Tomcat在运行时从源头获取对JSP文件所做的更改而不重新启动.
应用程序已达到相当大的规模,我们需要在Web项目之外的几个不同位置重用大量类,因此我们将代码库重构为多模块Maven项目.结构现在是:
parent Maven POM
|
---- artifact1.jar
|
---- artifact2.jar -> depends on artifact1.jar
|
---- artifact3.jar -> depends on artifact1.jar
|
---- artifact4.jar -> depends on artifact2.jar and artifact3.jar
|
---- artifact5.war -> depends on artifact1.jar, artifact2.jar, artifact3.jar and artifact4.jar
Run Code Online (Sandbox Code Playgroud)
在重构之后我们无法使用tomcat:从项目的根目录运行以运行WAR项目,因为插件无法检测到JAR工件.所以,我们切换到使用tomcat:run-war-only插件.WAR模块现在启动正常.
但是,从文档中可以看出,仅运行战争目标将WAR文件视为打包的Web应用程序.因此,我们对JSP文件所做的任何更改现在都不会被嵌入式Tomcat服务器在运行时获取.对于JSP文件的每次更改,我们都必须重新启动服务器.
我们在这个多模块Maven中是否有办法将WAR项目作为动态Web应用程序运行,以便Tomcat至少可以在不重新启动的情况下获取对JSP文件的更改?
在tomcat7-maven-plugin允许运行当前项目作为一个Web应用程序和额外的<webapps>可指定将被同时加载到Tomcat.
我的项目不是Web应用程序,但它访问webapps提供的服务.那么如何在不将项目本身作为webapp运行的情况下部署大量的Web应用程序呢?以下Maven代码段导致FileNotFoundExceptions,因为找不到context.xml.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>run-tomcat</id>
<phase>${tomcat.run.phase}</phase>
<goals><goal>run-war-only</goal></goals>
<configuration>
<webapps>
<webapp>
<contextPath>/my/app1</contextPath>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<type>war</type>
<asWebapp>true</asWebapp>
</webapp>
... possibly more webapps ...
</webapps>
</configuration>
</execution>
<execution>
<id>tomcat-shutdown</id>
<phase>${tomcat.shutdown.phase}</phase>
<goals><goal>shutdown</goal></goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
解决方法:
即使您的应用程序本身不是webapp,您也需要为它配置a path和a contextFile:
<configuration>
<path>/my/non/existing/webapp</path>
<contextFile>src/test/resources/context.xml</contextFile>
<webapps>
...
Run Code Online (Sandbox Code Playgroud)
指定的context.xml文件必须存在.以下对我有用,即使web.xml文件不存在:
<?xml version="1.0" encoding="utf-8"?>
<Context path="/my/non/existing/webapp">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
Run Code Online (Sandbox Code Playgroud) 什么是maven noob,我试图理解它们之间的区别
tomcat:run-war
和
tomcat:run-war-only
对于不熟悉环境的人来说,Apache文档意义不大:
tomcat7:run-war 使用嵌入式Tomcat服务器将当前项目作为打包的Web应用程序运行.
tomcat7:run-war-only 使用嵌入式Tomcat服务器将当前项目作为打包的Web应用程序运行,而不会分配打包周期.
外行人的条款有什么不同?
我构建了一个没有任何XML的java配置的Spring MVC应用程序.我可以在笔记本电脑上部署和启动应用程序,没有任何问题.但是当我尝试在我的testserver(tomcat 7)上部署我的应用程序时,我收到以下消息:
HTTP Status 404 - The requested resource (/[application context]/) is not available.
Run Code Online (Sandbox Code Playgroud)
我使用Eclipse Maven插件构建我的应用程序.是否可以在没有web.xml的情况下部署应用程序,如果没有,哪个是我真正需要的基本web.xml?
Maven WAR插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven.war.plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
WebAppInitializer:
@Order(value = 1)
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
}
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { HibernateConfig.class, SecurityConfig.class, HibernateDaoConfig.class };
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { WebAppConfig.class };
}
@Override
protected String[] getServletMappings() {
return new …Run Code Online (Sandbox Code Playgroud) 我喜欢使用tomcat7-maven-plugin开发,特别是mvn tomcat7:run/tomcat7:run-war目标,以便快速测试我的应用程序,
这个插件允许你指定一个自定义的Context.xml(这对于为jndi数据源提供存根非常方便)
我的问题是,我想不出一个存储这个Context.xml的好地方.它根本不适合maven标准目录布局......
任何的想法 ?最佳做法?:d
谢谢,
好的,所以我一直在阅读其他几个堆栈问题并尝试将它们拼凑在一起,没有太多运气.基本上我的方法是我目前有一个项目有多个子项目.我基本上有以下几点:
root
|----backend
|----|----src
|----|----|----main
|----|----|----|----java (individual java files not shown)
|----|----|----|----resources
|----|----|----|----|----META-INF
|----|----|----|----|----|----applicationContext.xml
|----|----|----|----webapp
|----|----|----|----|----WEB-INF
|----|----|----|----|----|----web_servicesConfig.xml
|----|----|----|----|----|----web.xml
|----|----pom.xml
|----deploy
|----|----src
|----|----|----main
|----|----|----|----resources (properties files for tomcat)
|----|----pom.xml
|----frontend
|----|----app
|----|----|----angular files
|----|----bower_components
|----|----|----bower files
|----|----bower.json
|----|----Gruntfile.js
|----|----pom.xml
Run Code Online (Sandbox Code Playgroud)
好吧希望在文件结构上足够清楚.我打算使用maven-grunt-plugin,所以我可以在前端运行我的grunt命令.前端基本上与角度产生的设置相同或者至少是目标.部署只是设置tomcat,后端保存Spring 4 restful services/api.
好的,这就是我很困惑并寻求帮助.我不知道如何让前端与后端正常工作.基本上我想知道是否有办法告诉maven以启动模式启动Tomcat和Grunt服务器,以便我可以使用它们的两个功能来快速开发我的项目,然后将min文件拉入生产构建的战争中.我想我无法弄清楚如何让一切都很好地融合在一起.我查看了这个问题,但是我仍然感到困惑:
如何在同一个域/服务器上部署AngularJS app和Spring Restful API服务?
我希望任何链接到教程,以解决如何使用Maven与tomcat,spring,angularjs和grunt ...还凉亭,所以我可以使用它为我的前端包管理.我已经阅读了几个例子,并且已经看到很多关于如何在Java EE和jsp中使用spring的讨论.或者使用Gradle来做我想要的一些事情......但是没有像我正在尝试的那样.
当然,如果这是一个糟糕的方法让我知道.基本上我想让我的子项目尽可能分开,同时仍允许开发人员从一个pom文件导入/运行.
我想要一个不会存在于pom.xml文件内部(以及任何项目文件中)的插件配置.
我想要做的是拥有一个只能由我在工作站上使用的插件.具体来说,我想将我的项目部署到Tomcat 7容器上,为此我想使用Apache Tomcat Maven插件,但由于不同的开发人员可能想要使用不同的服务器或整个部署方式,我不想将此配置放入这个pom.xml.
在Maven中是否可以拥有这样的全局/用户特定的插件配置?
我使用tomcat7和tomcat-maven插件.我可以让它热切换我的jsp但它只有在我直接在目标中修改它才有效.如何让tomcat也在我的sources目录中查找更改?
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<serverXml>${project.build.directory}/config/tomcat-config/${usingDb}/server.xml</serverXml>
<tomcatUsers>${project.build.directory}/config/tomcat-config/tomcat-users.xml</tomcatUsers>
<configurationDir>${project.build.directory}/config/tomcat-config</configurationDir>
<additionalClassesDirs>
<classesDir>${project.basedir}/src/main/webapp</classesDir>
</additionalClassesDirs>
<contextReloadable>true</contextReloadable>
<port>${tomcat.http.local.port}</port>
<path>/${url.contextPath}</path>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)