在eclipse中,首先建一个gradle的工程,然后在工程上点击右键,properties,--》project facets,然后勾选Dynamic Web Module,Java,javascript。这三个。然后转换。再在gradle.build中修改如下,以下为完整代码。完毕后,在工程右键点击gradle,-->refresh,刷新即可让gradle下载类库。
/* * This file was generated by the Gradle 'init' task. * * This generated file contains a sample Java Library project to get you started. * For more details take a look at the Java Libraries chapter in the Gradle * user guide available at https://docs.gradle.org/4.8.1/userguide/java_library_plugin.html */ plugins { // Apply the java-library plugin to add support for Java Library id 'java-library' } dependencies { // struts library compile group: 'org.apache.struts', name: 'struts2-core', version: '2.3.24.1' compile 'org.apache.struts:struts2-spring-plugin:2.3.24.1' compile 'org.apache.struts:struts2-json-plugin:2.3.24.1' // spring library compile group: 'org.springframework', name: 'spring-core', version: '4.2.3.RELEASE' compile group: 'org.springframework', name: 'spring-web', version: '4.2.3.RELEASE' compile group: 'org.springframework', name: 'spring-orm', version: '4.2.3.RELEASE' compile group: 'org.springframework', name: 'spring-aop', version: '4.2.3.RELEASE' compile group: 'org.springframework', name: 'spring-aspects', version: '4.2.3.RELEASE' compile group: 'org.springframework', name: 'spring-jdbc', version: '4.2.3.RELEASE' // hibernate library compile group: 'org.hibernate', name: 'hibernate-core', version: '5.0.1.Final' // common library compile 'org.slf4j:slf4j-api:1.7.13' testCompile 'junit:junit:4.12' // This dependency is exported to consumers, that is to say found on their compile classpath. api 'org.apache.commons:commons-math3:3.6.1' // This dependency is used internally, and not exposed to consumers on their own compile classpath. implementation 'com.google.guava:guava:23.0' // Use JUnit test framework testImplementation 'junit:junit:4.12' } // In this section you declare where to find the dependencies of your project repositories { // Use jcenter for resolving your dependencies. // You can declare any Maven/Ivy/file repository here. jcenter() }