maven导入第三方包后出现启动时springmaven找不到jar包本地类的情况,求解答

maven创建web工程,加入这些依赖后启动报错,去掉后能正常启动可访问,求能人出手啊_百度知道
maven创建web工程,加入这些依赖后启动报错,去掉后能正常启动可访问,求能人出手啊
groupId&gt:150) at org.java.loadClass(DefaultInstanceManager.core:512) at
&lt.springframework&lt:1571)
&lt.springframework&lt.version}&lt.javaee-api&
&dependency&groupId&gt.
&lt.version}&lt.${spring.apache.dependency&gt:530) at org.springframework&artifactId&
&lt.listenerStart(StandardCspring-aop&
&lt.util.&#47.dependency&&#47.spring-context&lt.${
&lt.faces.lang.java.lang:25 下午 org.ThreadPoolE/
org.WebappClassL/
&&#47.apache.loadClass(WebappClassLoader.WebappClassLoader:1565) &#47.
&version&gt.newInstance(DefaultInstanceMversion&gt:615) at java.
&groupId&gt.run(TgroupId&gt.ConfigureListener/
&artifactId&groupId&
&lt.call(ContainerBartifactId&/&#47.DefaultInstanceManager./
&spring-core&
&${version&artifactId&version&org:&#47./6.version}&dependency&
&lt.catalina:59;
&${groupId&
&lt.loadClass(WebappClassL/groupId&gt:59.version}&groupId&gt.run(ThreadPoolExecutor./dependency&gt.ClassNotFoundException.java.groupId&gt.StandardCversion&gt.ContainerBase$StartCversion&
&groupId&artifactId&gt:745)五月 22;
&lt.apache.springframework&lt.StandardContext listenerStart严重;version&gt.
&&#47.version}&
&lt.catalina.artifactId&dependency&dependency&gt: Error configuring application l&#47.&#47:1145)
&lt.concurrent.StandardCdependency&gt.loader.util:1575) at org.springframework&dependencies&spring-context-support&lt.&lt:5490) ${artifactId&artifactId&org.call(ContainerBartifactId&gt.dependency&groupId&version&&#47.FutureTask.
&lt.springframework&artifactId&gt.artifactId&&#47:262) javax&lt.
&lt.java.apache.version}&lt.ThreadPoolExecutor$Wdependency&gt.version&gt.startInternal(StandardContext.loadClassMaybePrivileged(DefaultInstanceManager.groupId&gt.catalina.runWorker(ThreadPoolE&#47.
&lt.catalina.&#47.catalina.ConfigureListener at org:1720) at org.catalina.&#47.start(LifecycleBdependency&gt五月 22.DefaultInstanceManager.util, 2016 9;
&version&version&gt.0&&#47.apache./version&gt:4907) at org:139) artifactId&gt.java.
&spring-webmvc&
&lt:25 下午&#47.spring-jdbc&lt.version&gt.
&lt.java.LifecycleBase.run(FutureT/groupId&artifactId&version&gt.java.ContainerBase$StartChild.dependency&&#47.${dependency&gt.DefaultInstanceMdependency&artifactId&gt, 2016 9;&#47.apache.StandardContext listenerStart严重.apache
4删除默认的resource包再次打开java build path选择resource,被当成资源文件了。输入target&#47,编译输出的目标文件夹不会自动改变打开java build path编辑output folder弹出界面选择specific output folder!运行main方法测试报错找不到自身类。3右键项目---properties 选择java build path弹出界面勾选allow output folders for source folders 确认退出重新打开发现勾又去掉了,没有任何效果。,新建源文件夹在新的文件夹下新建测试类,点击remove,报找不到类删除原有resource包后,直接删除掉END运行main方法.ClassNotFoundException。ok图标一切正常。: java.lang:重新新建源文件夹后;classes确认再次运行Java图标空心1新建一个测试项目新建maven项目--maven archetype webapp2新建测试类右键项目新建出来的类,前面的小图标“J”是空心的
来自团队:
其他类似问题
为您推荐:
maven的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁maven 构建 jar包 运行时提示找不到spring-beans-4.2.xsd
- 开源中国社区
当前访客身份:游客 [
当前位置:
maven 构建 jar包 运行时提示找不到spring-beans-4.2.xsd,这个有时报错有时报错,很是奇怪,有没有遇到类似的,麻烦指点一二。
maven pox.xml&中 build&配置如下:
&finalName&pssServer&/finalName&
&artifactId&maven-assembly-plugin&/artifactId&
&configuration&
&encoding&UTF-8&/encoding&
&manifest&
&!-- &addClasspath&true&/addClasspath& &classpathPrefix&config/&/classpathPrefix& --&
&!--这里要替换成jar包main方法所在类 --&
&mainClass&com.xkzh.pss.server.NettyServerStart&/mainClass&
&/manifest&
&/archive&
&descriptorRefs&
&descriptorRef&jar-with-dependencies&/descriptorRef&
&/descriptorRefs&
&/configuration&
&executions&
&execution&
&id&make-assembly&/id& &!-- this is used for inheritance merges --&
&phase&package&/phase& &!-- 指定在打包节点执行jar包合并操作 --&
&goal&single&/goal&
&/execution&
&/executions&
&/plugins&
spring 头部配置如下:
&?xml version="1.0" encoding="UTF-8"?&
&beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd" default-init-method="init"&
错误提示如下:
org.xml.sax.SAXParseE lineNumber: 9; columnNumber: 106;
schema_reference.4: Failed to read schema document '
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd',
because 1) could n 2) the docume
3) the root element of the document is not &xsd:schema&.
共有1个答案
<span class="a_vote_num" id="a_vote_num_
配置依赖没有哦
--- 共有 4 条评论 ---
: 找到原因了,是maven 打包问题,换了一种打包方式就可以了
(4个月前)&nbsp&
: 关键是有没有配置正确
(4个月前)&nbsp&
如果你说的是jar 包的话是有配置的,只是没放在上面,上面只是放了build 相应的配置
(4个月前)&nbsp&
麻烦能详细点么?因为是第一次使用maven
(4个月前)&nbsp&
更多开发者职位上
有什么技术问题吗?
e_peng...的其它问题
类似的话题4305人阅读
Maven(1)
最近一些项目需要让Maven来管理,一种情况是将之前的eclipse的Java Project项目和Web project 加入Maven管理,还有一种情况是,将SVN上的Maven项目拉到本地,在eclipse中使用时遇到的一些棘手问题,问题过程和解决具体方案如下:
1.在eclipse中安装maven插件后启动eclipse时,会遇到如下警告:
The Maven Integration requires that Eclipse be running in a JDK, because a number of Maven core plugins are using jars from the JDK
Please make sure the -vm option in eclipse.ini is pointing to a JDK and verify that Installed JRE’s are also using JDK installs.
2.使用maven插件在eclipse中编译或者Maven Install时有时会出现会出现如下问题:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project springside-core: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
以上两个问题解决方法如下:
(1)set your JDK as a default Java environment in eclipse (default installed JRE)
Open eclipse. Click on ‘Window’ -& ‘Preferences’ -& ‘Java’ -& ‘Installed JREs’.
If you can’t find any JDK on the list -& click ‘Add’ -& ‘Standard VM’ -& set all paths and click ‘Finish’.
After that – check this JDK on the list of installed JREs and click ‘OK’.
有时采取第(1)种方案并不能有效解决问题,还需要如下处理:
(2)add path to your SDK in eclipse.ini
open ‘eclipse.ini’ and add there: -vm path_to_javaw_on_your_machine,so in my example it will be (jdk1.6.0_17 on Windows):
D:\\Java\jdk1.6.0_13\jre\bin\javaw
your ‘eclipse.ini’ looks like this:
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
D:\Java\jdk1.6.0_13\jre\bin\javaw
注:‘-vm’ must be& &-vmargs& above
3.使用Maven,经常会自己搭建nexus私服,具体步骤如下:
建立私服的优点:
&(1) 降低中央仓库负荷
&(2) 节省外网带宽
&(3) 加速Maven构建
&(4) 自己部署构件
1). Nexus安装
&&& (1) 下载:http://www.sonatype.org/nexus/,下载包:nexus-2.0.2.war
&&& (2) 安装
&&&&&&&& A. WAR方式安装Nexus
&&&&&&&& 将nexus-2.0.2.war拷贝至Tomcat的部署目录:C:\Apache-tomcat-7.0.26\webapps下,
&&&&&&&& 启动Tomcat, 进入Tomcat管理首页即可;
&&&&&&&& 浏览器访问地址:http://localhost:8080/nexus
&&&&&&&& B. Bundle方式安装Nexus
&&&&&&&& 因为Bundle方式的Nexus默认集成了Jetty容器,因此不需要其他第三方Web容器,解压下载的Bundle
&&&&&&&& 方式的Nexus文件,有下面的两个目录:
&&&&&&&& nexus-webapp-2.0.2:包含Nexus所需要的文件,如启动脚本,依赖JAR等。
&&&&&&&& sonatype-work:包含Nexus生成的配置文件、日志文件、仓库文件。
&&&&&&&& WinOS下,进入nexus-webapp-2.0.2/bin/jsw/windows-x86-32运行nexus.bat脚本启动服务。
&&&&&&&& 浏览器访问地址:http://localhost:8081/nexus
&&&&&&&& 备注:
&&&&&&&& 更改访问端口:修改nexus-webapp-2.0.2/conf/plexus.properties
&&& (3) 登录
&&&&&&&& Nexus默认的管理员及密码:admin/admin123
2). Nexus的仓库与仓库组
&&& Nexus有四种仓库类型:group,hosted,proxy,virtual,仓库&#26684;式为:maven2或maven1,仓库属性Policy为:Release或Snapshot.
3.设置本地Maven库步骤和在eclipse中使用Maven遇到的一些问题及解决方案如下:
以下是在D:\Java\apache-maven-3.0.1\conf的settings.xml文件中配置,maven的settings.xml是全局设置,下面会在eclipse中使用该自定义的maven:
1).设置本地Maven库地址:
&localRepository&D:/Java/maven_repository&/localRepository&
2).建立nexus私服后,设置访问服务器的账号和密码:
&&& &server&
&& &&& &&id&nexus-releases&/id&
&& &&& &&username&admin&/username&
&& &&& &&password&admin123&/password&
&& &&/server&
&& &&server&
&& &&& &&id&nexus-snapshots&/id&
&& &&& &&username&admin&/username&
&& &&& &&password&admin123&/password&
&& &&/server&
3).有关在settings.xml配置镜像
简单讲一下为什么我们需要配置镜像,如果不配置镜像,你会发现maven默认从http://repo1.maven.org/maven2地址去下载的,这是为什么呢?
原因如下:在D:\Java\apache-maven-3.0.1\lib\maven-model-builder-3.0.1.jar的jar包你会发现有个maven-model-builder-3.0.1.jar\org\apache\maven\model\pom-4.0.0.xml文件,里面指定了如下配置
& &repositories&
&&& &repository&
&&&&& &id&central&/id&
&&&&& &name&Maven Repository Switchboard&/name&
&&&&& &url&http://repo1.maven.org/maven2&/url&
&&&&& &layout&default&/layout&
&&&&& &snapshots&
&&&&&&& &enabled&false&/enabled&
&&&&& &/snapshots&
&&& &/repository&
& &/repositories&
& &pluginRepositories&
&&& &pluginRepository&
&&&&& &id&central&/id&
&&&&& &name&Maven Plugin Repository&/name&
&&&&& &url&http://repo1.maven.org/maven2&/url&
&&&&& &layout&default&/layout&
&&&&& &snapshots&
&&&&&&& &enabled&false&/enabled&
&&&&& &/snapshots&
&&&&& &releases&
&&&&&&& &updatePolicy&never&/updatePolicy&
&&&&& &/releases&
&&& &/pluginRepository&
& &/pluginRepositories&
如果让我们本机的Maven只使用私服,即覆盖如上中央仓库的默认地址,则需要配置如下镜像:
&&& &mirror&
&& &&& &&id&Mirror&/id&
&&&&&& &!--如果想为所有的仓库做镜像那么这里加*--&
&& &&& &&mirrorOf&*&/mirrorOf&
&& &&& &&name&Mirror&/name&
&& &&& &&url&http://172.16.101.17:8081/nexus/content/groups/public/&/url&
&& &&/mirror&
4).在settings.xml配置获取依赖包和插件如下:
&&&& &profile&
&& &&& &&id&nexus&/id&
&& &&& &&repositories&
&& &&& &&& &&repository&
&& &&& &&& &&& &&id&nexus&/id&
&& &&& &&& &&& &&name&Nexus&/name&
&& &&& &&& &&& &&url&http://172.16.101.17:8081/nexus/content/groups/public/&/url&
&& &&& &&& &&& &&releases&
&& &&& &&& &&& &&& &&enabled&true&/enabled&
&& &&& &&& &&& &&/releases&
&& &&& &&& &&& &&snapshots&
&& &&& &&& &&& &&& &&enabled&true&/enabled&
&& &&& &&& &&& &&/snapshots&
&& &&& &&& &&/repository&
&& &&& &&/repositories&
&& &&& &&pluginRepositories&
&& &&& &&& &&pluginRepository&
&& &&& &&& &&& &&id&nexus&/id&
&& &&& &&& &&& &&name&Nexus&/name&
&& &&& &&& &&& &&url&http://172.16.101.17:8081/nexus/content/groups/public/&/url&
&& &&& &&& &&& &&releases&
&& &&& &&& &&& &&& &&enabled&true&/enabled&
&& &&& &&& &&& &&/releases&
&& &&& &&& &&& &&snapshots&
&& &&& &&& &&& &&& &&enabled&true&/enabled&
&& &&& &&& &&& &&/snapshots&
&& &&& &&& &&/pluginRepository&
&& &&& &&/pluginRepositories&
&& &&/profile&
5).在eclipse中配置上面自定义的的maven,如下图:
6).eclipse中的项目更新依赖的jar包和系统Maven配置方法如下图:
7).下面的配置可以在每个项目的pom文件中设置,目的是将本地项目使用Maven部署构件至Nexus库中:
&&& &distributionManagement&
&& &&& &&repository&
&& &&& &&& &&id&nexus-releases&/id&
&& &&& &&& &&name&Nexus Releases Repository&/name&
&& &&& &&& &&url&http://172.16.101.17:8081/nexus/content/repositories/releases/&/url&
&& &&& &&/repository&
&& &&& &&snapshotRepository&
&& &&& &&& &&id&nexus-snapshots&/id&
&& &&& &&& &&name&Nexus Snapshots Repository&/name&
&& &&& &&& &&url&http://172.16.101.17:8081/nexus/content/repositories/snapshots/&/url&
&& &&& &&/snapshotRepository&
&& &&/distributionManagement&
4.下面的问题是个比较重要的问题,也提供解决方法:
&&& 我向来喜欢用简单的工具,因为开发效率高的同时,调试和查问题也会变得很简单,如果我们平时使用myeclipse作为开发工具来,会习惯使用它自带的集成tomcat工具,版本低的eclipse只能配置tomcat6,不能配置tomcat7等高版本,其实这个也是有解决方法的,后面再说。
&&& 如果我们使用maven这个插件来开发,部分人会使用jetty插件或者tomcat插件来部署应用,如果部署的应用有一些问题,比如:我们有时会需要到web容器中查找有没有部署成功等等,如果此时使用插件,可能有点不方便,这时候就会觉得myeclipse自带的集成tomcat环境有很大用处,但是这里会存在一个部署问题如下图:
按照maven的结构,编译之后的代码都是默认放在${project_name}/target/classes下的,但是你部署到tomcat的路径是如下图:
这样就会存在一个问题,如果你修改的工程代码,工程代码不会实时更新到web容器中,至于什么原因,大家通过比较上面两张图应该能看出,所以我们要解决这些默认问题,解决问题如下:
即将${project_name}/target/classes改为${project_name}/src/main/webapp/WEB-INF/classes即可,注意图中编译之后的class文件存放路径等细节。
5.有时我们在使用Maven命令做编译或者Maven Install时,可能需要跳过TestCase检验,方案如下:
1.在pom.xml文件中,追加如下插件
&&&&&plugin&
&&&&&&&groupId&org.apache.maven.plugins&/groupId&
&&&&&&&artifactId&maven-surefire-plugin&/artifactId&
&&&&&&&version&2.12.4&/version&
&&&&&&&configuration&
&&&&&&&&&skipTests&true&/skipTests&
&&&&&&&/configuration&
&&&&/plugin&
2.或者在使用mvn install命令的时候,加上如下参数:
mvn install -D maven.test.skip=true&&& 注:加了则跳过TestCase检验,否则在install时会运行TestCase测试。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:353721次
积分:1413
积分:1413
排名:千里之外
原创:21篇
转载:15篇
评论:185条
(2)(4)(2)(4)(1)(5)(10)(3)(5)maven导入第三方包后出现启动时spring找不到本地类的景况,求解答 - Java Web开发当前位置:& &&&maven导入第三方包后出现启动时spring找不到本地类maven导入第三方包后出现启动时spring找不到本地类的景况,求解答&&网友分享于:&&浏览:0次maven导入第三方包后出现启动时spring找不到本地类的情况,求解答这是本地类的定义
public&class&Constants&{&&
//&&public&final&static&String&defautLoginUrl&=&"/union/sid.action";&&
&&&&/**&会话过期时间-单位为秒&*/&&
&&&&public&static&int&SESSION_TIMEOUT&=&3600;&&
&&&&public&static&String&REWARD&=&"reward";&&
&&&&public&static&final&String&USER_INFO_KEY&=&"USER_INFO";&&
&&&&public&static&final&String&SID&=&"sid";&&
&&&&public&static&String&loginurl&&=&&&"/union/sid.action";&&
&&&&public&static&String&getloginurl()&{&&
&&&&&&&&return&&&
&&&&public&static&void&setloginurl(String&loginURL)&{&&
&&&&&&&&loginurl&=&loginURL;&&
&&&&public&static&final&String&E_SURVEY_ID&=&"eSurveyId";&&
&&&&public&static&final&String&PROJECT&=&"survey";&&
这个是spring的配置文件
&bean&class="com.jcloud.survey.Constants"&
&property&name="loginurl"&value="${survey.login.url}"&/&
在pom.xml文件中引入
&&&& &dependency&
&groupId&com.xx.m.server&/groupId&
&artifactId&session-common&/artifactId&
&version&1.0.3-SNAPSHOT&/version&
&/dependency&
&dependency&
&groupId&com.xx.m.server&/groupId&
&artifactId&session-client&/artifactId&
&version&1.0.3-SNAPSHOT&/version&
&/dependency&
后出现:&Cannot&find&class&[com.jcloud.survey.Constants]&for&bean&with&name&'com.jcloud.survey.Constants#0'&defined&in&class&path&resource&[spring/spring-config-config.xml];&nested&exception&is&:&com.jcloud.survey.Constants
的情况。这个类我在本地是有的,通过mave生成jar导入到web工程里面,但是启动时就出现以上的错误。
找了很多办法,都不奏效,求解惑------解决思路----------------------你看看在web的运行时环境里面有没有这个class------解决思路----------------------引用:Quote: 引用:
你看看在web的运行时环境里面有没有这个class
我在web项目里lib文件夹下找到那个jar包,反编译一下,是有这个类的
看的是运行时&不是工程里面的lib------解决思路----------------------如果可以的话&&把spring相关的包都更新一下,应该是某些包的版本对不上------解决思路----------------------查检一下运行环境JAVA版本,再检查一下SPRING的版本,4以下的SPRING在1.8以下的JAVA环境中运行。
4以上的在1.8的JAVA中运行。
12345678910
12345678910
12345678910 上一篇:下一篇:文章评论相关解决方案 12345678910 Copyright & &&版权所有tomcat在发布项目的时候没有同时发布maven依赖所添加的jar包,所以找不到解决方法:设置一下eclipse:项目 —& properties -& Deployment Assembly -& Add -& Java Build Path Entries -& 选择Maven Dependencies -& Finish -& OK把对应的Maven依赖包也发布到tomcat,调试时会自动把那些jar发布到指定目录下,tomcat也能找到那些jar了。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:3065次
排名:千里之外
原创:16篇
(1)(1)(2)(1)(1)(3)(6)(5)(3)(1)

我要回帖

更多关于 maven 找不到符号 的文章

 

随机推荐