---
title: "如何解决struts2与json包冲突的问题"
author: "boss5518831534"
date: "2012-02-29T11:02:59Z"
tags: []
categories: ["编程语言"]
slug: "struts2-json"
draft: false
lastmod: "2012-02-29T11:02:59Z"
id: 1431589
url: "https://garson.iteye.com/blog/1431589"
---

今天做项目需要用到json包，于是就将struts2与json整合，结果启动tomcat的时候发现报如下错误：
json包：json-lib-2.1.jar  struts2-json-plugin-2.1.8.1.jar jsonplugin-0.34.jar


Caused by: The package name 'json-default' at location package - jar:file:/C:/Tools/Soft/tomcat6.0.33/webapps/music/WEB-INF/lib/struts2-json-plugin-2.1.8.1.jar!/struts-plugin.xml:8:59 is already been used by another package at location package - jar:file:/C:/Tools/Soft/tomcat6.0.33/webapps/music/WEB-INF/lib/jsonplugin-0.34.jar!/struts-plugin.xml:8:59 - package - jar:file:/C:/Tools/Soft/tomcat6.0.33/webapps/music/WEB-INF/lib/struts2-json-plugin-2.1.8.1.jar!/struts-plugin.xml:8:59
	at com.opensymphony.xwork2.config.impl.DefaultConfiguration.addPackageConfig(DefaultConfiguration.java:124)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:486)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275)
	at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
	at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204)
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
	... 31 more

出现这个问题原来是 struts2-json-plugin-2.1.8.1.jar jsonplugin-0.34.jar 有冲突，只需要将jsonplugin-0.34.jar替换成json-lib-2.1.jar、struts2-json-plugin-2.1.8.1.jar、struts2-junit-plugin-2.1.8.1.jar 使用这三个包就不会出现冲突了