private  String target =  getTarget();????unreported exception org.apache.commonms.configuration.ConfiguationException ;must be caught or declared to be thrown
    
    public static String getTarget() throws ConfigurationException {
     String target = "";
     ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        URL url = classLoader.getResource("org/seatore/resources/targetMachine.properties");
     try {
         Configuration config = new PropertiesConfiguration(url);
         target = config.getString("target.ip");
         logger.info("Connect to the machine:" + target);        }catch (ConfigurationException e) {
        
        }
        return target;
    }
就是这句报错啊,而且我已经导入了
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.ConfigurationException;
请问这个是这么回事?

解决方案 »

  1.   


        public static String getTarget() throws ConfigurationException /*抛出异常?*/
         String target = ""; 
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); 
            URL url = classLoader.getResource("org/seatore/resources/targetMachine.properties"); 
         try /*捕获异常?*/
             Configuration config = new PropertiesConfiguration(url); 
             target = config.getString("target.ip"); 
             logger.info("Connect to the machine:" + target);         }catch (ConfigurationException e) { 
             
            } 
            return target; 
        } 
    这样有什么意义么?