Có cách nào để làm những gì các tập tin Config.groovy
không, nhưng trong quá trình thực thi mã ...
Cái gì như:Grails thực thi mã mỗi môi trường
class AController{ def method(){ withEnvironments{ development{ println 'This is execute just on development' } production { log.debug 'This is execute just on production' } } } }
tôi biết rằng tôi có thể đạt được hiệu quả tương tự sử dụng if (Environment.current == 'development')
, nhưng có cái gì đó với sintax ???
chỉnh chỉ nhỏ if (. Environment.getCurrent() equals (Environment.DEVELOPMENT)) –
@AramArabyan Một cách groovier nói đó là : 'if (Environment.current == Environment.DEVELOPMENT)' –
Đối với nhà phát triển lười biếng lười biếng trở thành nếu (Environment.current == 'development') khi mã không phải làm việc :) – rascio